Re: packing things back to regular expression

2008-02-24 Thread Amit Gupta
> "CL(?P[a-z]+)XY(?:AB)[aeiou]+(?PCD(?P..)\?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 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(?P[a-z]+)") > > # group name "name1" is attached to the match of

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(?P[a-z]+)") > > # group name "name1" is attached to the match of lowercase string of > alphabet > # Now I have a dictionary saying {"name1", "iamgood

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(?P[a-z]+)") > # group name "name1" is attached to the match of lowercase string of > alphabet > # Now I have a dictionary saying {"name1", "iamgood"}

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(?P[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 "C

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

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 = ([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