467,076 Members | 960 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,076 developers. It's quick & easy.

Regular Expression

Hi...
I'm using IDLE version 2.5.1 with django 0.97 pre in xp. I'm completely new to this so forgive me if this sounds stupid. I'm trying to use regular exp for url config but i cannot escape the '?' in the string using '\' .
urlpatterns = patterns('',(r'^circle/\?ent_value=\d+/$',current_datetime))
Can anybody tell me the error? I tried to work this without the '?' and it works fine.... Is there some way to do this? HELP
Aug 24 '07 #1
  • viewed: 767
Share:
4 Replies
bartonc
Expert 4TB
Hi...
I'm using IDLE version 2.5.1 with django 0.97 pre in xp. I'm completely new to this so forgive me if this sounds stupid. I'm trying to use regular exp for url config but i cannot escape the '?' in the string using '\' .
urlpatterns = patterns('',(r'^circle/\?ent_value=\d+/$',current_datetime))
Can anybody tell me the error? I tried to work this without the '?' and it works fine.... Is there some way to do this? HELP
Character classes generally remove the special meaning from metacharacters:

Expand|Select|Wrap|Line Numbers
  1. [?]
This trick proved useful lately what someone needed the left brace in their expression:

Expand|Select|Wrap|Line Numbers
  1. [[]
Aug 24 '07 #2
Expert 256MB
Hi...
I'm using IDLE version 2.5.1 with django 0.97 pre in xp. I'm completely new to this so forgive me if this sounds stupid. I'm trying to use regular exp for url config but i cannot escape the '?' in the string using '\' .
urlpatterns = patterns('',(r'^circle/\?ent_value=\d+/$',current_datetime))
Can anybody tell me the error? I tried to work this without the '?' and it works fine.... Is there some way to do this? HELP
you can try re.escape() during you pattern compilation
Aug 24 '07 #3
you can try re.escape() during you pattern compilation

Hi... Thanks alot for the reply.. The problem is I want to know why this doesn't work after giving the escape character '\' . I tried to match it with ' .* ' which should've matched everything.. But it just doesn't take '?' . I tried google but seems like nobody has this problem. So I must be doing something wrong, just don't know wht it is... Thanks once again for replying.
Aug 24 '07 #4
bartonc
Expert 4TB
Hi... Thanks alot for the reply.. The problem is I want to know why this doesn't work after giving the escape character '\' . I tried to match it with ' .* ' which should've matched everything.. But it just doesn't take '?' . I tried google but seems like nobody has this problem. So I must be doing something wrong, just don't know wht it is... Thanks once again for replying.
r'^circle/\?ent_value=\d+/$'
Could be the 'r' (raw string).
Aug 24 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Buddy | last post: by
4 posts views Thread by Neri | last post: by
11 posts views Thread by Dimitris Georgakopuolos | last post: by
3 posts views Thread by James D. Marshall | last post: by
7 posts views Thread by Billa | last post: by
9 posts views Thread by Pete Davis | last post: by
25 posts views Thread by Mike | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.