On 6/5/06, John M <[EMAIL PROTECTED]> wrote: > (r`^polls/$'....), > (r'^polls/(\d+)/$'....) > > how does that differ from > > (r'^polls/'....), > (r'^polls/(\d+)/$'....)
The strings in the first element of the tuple are regular expressions (aka regex). That's a complex but powerful text matching grammar. Typically, urlpatterns are relatively simple regexs. The "$" token is what's called a zero-width assertion, and in particular causes the text to match the expression iff the end of the line occurs at that point in the text being matched. Similarly, '^' matches iff the beginning of the line occurs at that point in the text being matched. Given r'^polls/$', you're saying "match iff the text is "polls/" preceeded by the beginning of the line and ending with the end of the line. The latter pattern doesn't work as expected because any URL starting with "polls/" will be matched, including ones like "polls/1". Kodos is a nice utility for fiddling with regexs: http://kodos.sourceforge.net/ And this site is a good place to start learning about them: http://www.regularexpressions.info/ If that's not enough, this is the regex bible: http://www.amazon.com/gp/product/0596002890/ Regexs are a common library tool in many prog langs now, but their grammar differs a bit for the various libraries. (Kodos uses Python's regex engine.) Welcome, newbie. :) --Jeremy --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---