Hi Andy, 2009/6/12 Andy Dietler <andydiet...@gmail.com>: > > Right now I've got a URL pattern that works for letters and numbers, > but when a character like %20 gets thrown in it fails. > > The pattern is this: > > (r'^(?P<title>\w+)/$', 'detail'), > > Which works when I have: > > domain.com/Friends/ > domain.com/24/ > > but not for > > domain.com/The%20Office/ > > How do I get it to accept the %20?
The `\w` in your regular expression means (to quote the Python `re` module documentation <http://docs.python.org/library/re.html>: > When the LOCALE and UNICODE flags are not specified, [`\w`] matches any > alphanumeric character and the underscore; this is equivalent to the set > [a-zA-Z0-9_]. With LOCALE, it will match the set [0-9_] plus whatever > characters are defined as alphanumeric for the current locale. If UNICODE is > set, this will match the characters [0-9_] plus whatever is classified as > alphanumeric in the Unicode character properties database. You need to replace the `\w` with something that will match the characters you want. If you want everything that `\w` matches plus spaces, you should use `[\w ]+` (note the space) instead of `\w+`. Cheers, Thomas Sutton --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---