regex-group

Dynamic direct_to_template

In my webapp, there are a lot of errors or other messages that just show a template that is very close to the URL. At the moment, I have half a dozen static mappers like this: (r'^/message/foo/$', 'direct_to_template', {'template': 'message/foo.html'}), (r'^/message/bar/$', 'direct_to_template', {'template': 'message/bar.html'}), Is t...

regex return conditional group

Hi , I spent lot time figuring out a simple regex to return a group (only 1st group). So the string can be - "No purchase required" or "Purchase of $50.00 worth groceries is required." I am trying to write a regex which can parse "No" or "50" based on the given string. This is what I have written. (?:(No) monthly maintenance|Purchas...

Simple python regex groups can't parse date

I'm trying to parse dates with regex, using groups, but python is returning empty lists. I'm not doing anything fancy, just 12/25/10 sort of stuff. I want it to reject 12/25-10 though. date = re.compile("\d{1,2}([/.-])\d{1,2}\1\d{2}") I've tried online regex libraries, but their solutions don't seem to run either. Any ideas? Sampl...