At this point I always love to refer to http://rubular.com, which is a very good regular expression editor and tester.
leon On Aug 11, 1:42 am, Tim Chase <django.us...@tim.thechases.com> wrote: > > If i have a URL such as: > > > (r'^(?P<username>\w+)/blog/', include('foo.urls.blog')), > > > what are the whats the purpose of the w and the +? i'm having some > > problems with 2 of my urls and i think it may have something to do > > with this. > > You'll want to read up on regular expressions. There are a > number of good tutorials and books on the subject. In short, in > this case the "\w" is "any 'word' character" (usually > [a-zA-Z0-9_] and if the regexp is compiled with unicode support, > I believe it supports unicode "letter/digit" type characters). > Note that this *doesn't* include things like the minus sign, the > "@", and a variety of other characters you might wish to include > in a username. > > The "+" is the "one-or-more of the previous atom [the '\w']" > repetition operator. So your regexp is "one or more 'word' > characters, followed by a slash, followed by the literal 'blog', > followed by another slash". > > Regexps are very powerful, though the regexp-reversing code in > Django doesn't gracefully handle some of the more complex cases > because it's a non-trivial problem. > > -tkc --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---