YANRQ (yet another regex question)
Michael George Lerner
mlerner at zektor.gpcc.itd.umich.edu
Wed Mar 13 17:39:58 EST 2002
Howdy,
I have a regular expression that looks vaguely like this:
r = re.compile(r'''(?P<start>start)(?P<foo> foo)(?P<end>end)''')
but the middle pattern isn't quite what I want. I know that foo
will be a string that is seven characters long and contains 'foo'
surrounded by spaces. That is, it could be any of these:
'foo '
' foo '
' foo '
' foo '
' foo'
I'd like to rewrite my regular expression to match any of these,
and I'd really rather not write it all out like this:
(?P<foo>(foo | foo | foo | foo | foo|)
Is there some easy way to do this that I've overlooked?
thanks,
-michael
More information about the Python-list
mailing list