Re: packing things back to regular expression

2008-02-24 Thread Amit Gupta
CL(?Pname1[a-z]+)XY(?:AB)[aeiou]+(?Pname2CD(?Pname3..)\?EF) Good luck. -- Steven This is what I did in the end (in principle). Thanks. A -- http://mail.python.org/mailman/listinfo/python-list

Re: packing things back to regular expression

2008-02-21 Thread MRAB
On Feb 20, 7:36 pm, Amit Gupta [EMAIL PROTECTED] wrote: Before I read the message: I screwed up. Let me write again x = re.compile(CL(?Pname1[a-z]+)) # group name name1 is attached to the match of lowercase string of alphabet # Now I have a dictionary saying {name1, iamgood} # I would

Re: packing things back to regular expression

2008-02-21 Thread Paul McGuire
On Feb 20, 6:29 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Wed, 20 Feb 2008 11:36:20 -0800, Amit Gupta wrote: Before I read the message: I screwed up. Let me write again x = re.compile(CL(?Pname1[a-z]+)) # group name name1 is attached to the match of lowercase

packing things back to regular expression

2008-02-20 Thread Amit Gupta
Hi I wonder if python has a function to pack things back into regexp, that has group names. e.g: exp = (?Pname1[a-z]+) compiledexp = re.compile(exp) Now, I have a dictionary mytable = {a : myname} Is there a way in re module, or elsewhere, where I can have it match the contents from dictionary

Re: packing things back to regular expression

2008-02-20 Thread Gary Herron
Amit Gupta wrote: Hi I wonder if python has a function to pack things back into regexp, that has group names. e.g: exp = (?Pname1[a-z]+) compiledexp = re.compile(exp) Now, I have a dictionary mytable = {a : myname} Is there a way in re module, or elsewhere, where I can have it match

Re: packing things back to regular expression

2008-02-20 Thread Amit Gupta
Before I read the message: I screwed up. Let me write again x = re.compile(CL(?Pname1[a-z]+)) # group name name1 is attached to the match of lowercase string of alphabet # Now I have a dictionary saying {name1, iamgood} # I would like a function, that takes x and my dictionary and return

Re: packing things back to regular expression

2008-02-20 Thread Tim Chase
mytable = {a : myname} re.SomeNewFunc(compilexp, mytable) myname how does SomeNewFunc know to pull a as opposed to any other key? mytable = {a : 1} re.SomeNewFunc(compileexp, mytable) ERROR You could do something like one of the following 3 functions: import re ERROR = 'ERROR'

Re: packing things back to regular expression

2008-02-20 Thread Steven D'Aprano
On Wed, 20 Feb 2008 11:36:20 -0800, Amit Gupta wrote: Before I read the message: I screwed up. Let me write again x = re.compile(CL(?Pname1[a-z]+)) # group name name1 is attached to the match of lowercase string of alphabet # Now I have a dictionary saying {name1, iamgood} # I would