> "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
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
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
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"}
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
> 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
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