On Mar 23, 2005, at 3:44 PM, Brian Deacon wrote:

In the interests of peace, I shall refrain from mentioning the non-Perl
language this is implemented in.  :)

Well, if it's Python then you can use the basic string interpolation stuff to build the string and hand it to re.compile().


largeMatch = "bigonewithfartoomanycharactersformetobecomfortablewith"
largeRegex = """(\s*%s\s*)\s+(\s%s\s)*""" % (largeMatch, largeMatch)
largeRegexCompiled = re.compile(largeRegex)

Python also has some facility for named parameters in strings and regexes, IIRC.

I would suggest doing some searches in recipes up on activestate:
http://aspn.activestate.com/ASPN/Cookbook/

-a

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to