In the python docs for regex there is the description of what the “.” does:
(Dot.) In the default mode, this matches any character except a
newline. If the DOTALL flag has been specified, this matches any
character including a newline.
For a project i do in Django i set up this regex:
url(r'^accounts/confirm/(.+)$', confirm,name='confirmation_view')
For all i understand, this should match any url that starts with ‘accounts/confirm/’, then followed by any number of arbitrary characters. These arbitrary characters are then passed to the function “confirm” as parameter. So far, so good.
So this regex should match
accounts/confirm/fb75c6529af9246e4e048d8a4298882909dc03ee0/
just as well as
accounts/confirm/fb75c6529af9246e4e-048d8a4298882909dc03ee0/
and
accounts/confirm/fb75c6529af9246e4e=048d8a4298882909dc03ee0/
and
accounts/confirm/fb75c6529af9246e4e%20048d8a4298882909dc03ee0/
That, at least, was what i thought it would do. But it doesn’t, it matches only the first one. Django keeps returning me a 404 on the other ones. Which i do not understand, because the (.+) part of the expression should mean “match one ore more of any character except a newline”.
edit:
As the comments and answers proved, i got the regex right. So this is now a question about: why is Django not returning the correct view, but a 404. Is it doing some stuff to the url before passing it to that regex?
A quick test confirms this should work:
This will return false on any non matches:
The problem must be elsewhere.