>> Is there any difference between:
>>
>> r'^accounts/(?P<slug>[\w-]+)/$'
>>
>> and
>>
>> r'^accounts/(?P<slug>[-\w]+)/$'
>
> they match the same.

To expand on Paul's answer, yes they're the same.  The only time 
order matters is detailed at [1] where the character-set "[...]" 
notation is detailed.  Namely it needs to be unambiguous to the 
RE parse...to include a "-" or a "]" character in your 
characterset, you can either place it as the first character, or 
preceed it with a backslash (or otherwise make it unambiguous). 
Thus, if you had a more limited characterset of, say, 
vowels+hyphen, this regexp

   '[aei-ou]'

is very different from

   '[-aeiou]'

or

   '[aeiou-]'

(the 2nd and 3rd are effectively the same)

As you learn regular expressions, you'll go through a couple phases:

1) what the #$%^ is all this line-noise?

2) regexps rock!  they'll solve any problem I throw at them!

3) regexps rock!  I now know what types of problems the solve 
well without abusing them

Welcome to the transition between steps #1 and #2 ;)

-tim


[1] http://docs.python.org/lib/re-syntax.html





--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to