mixing regular expression

Ian McMeans imcmeans at home.com
Sun Mar 17 00:46:11 EST 2002


How should go I about nesting regular expressions in python?

I want one huge regular expression to be composed of a bunch of others - is
there some way I can include a regular expression inside another?

Or should I do it with strings - just save each regular expression's string,
and then compile each combination separately?

What I mean is this:
foo = re.compile("someregexcode")
bar = re.compile("moreregexcode")

big = re.compile("foo|bar")

is that possible at all? To combine regular expression objects? Or do you
suggest that I just make strings for foo and bar, and then compile the
combined strings into big?





More information about the Python-list mailing list