Monday, May 23, 2011

Re: Parenthesis in regex in URLConf

On Mon, May 23, 2011 at 10:25 AM, Pedram <pedrambehroozi@gmail.com> wrote:
> Hello,
> I have a regular expression for usernames and I want to use this regex
> in my URLConf and bind that to a view. The problem is, I have
> parenthesis in my regex which should not consider as *args*. Here's my
> regex:
>
> ^[a-zA-Z0-9]+((\.[a-zA-Z0-9]+)|(_[a-zA-Z-0-9]+))*$
>
> Values in '()' are necessary in my regex but I don't want to pass
> these values to my view.
> What should I do?
>

http://docs.python.org/library/re.html

(?:...)
A non-capturing version of regular parentheses. Matches whatever
regular expression is inside the parentheses, but the substring
matched by the group cannot be retrieved after performing a match or
referenced later in the pattern.

Cheers

Tom

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment