Also quite effective is the solution coming from ... Perl combines regular expressions in one:
regexp-assembly accepts all the regular expression or string variants that you want to match, and then combine them into one. And yes, this changes the original problem to another, as it is not related to matching the matching regular expression anymore, but combining the regular expression to match
And then you can use it in your code:
$ python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.sub("I am foo","I am(?: foo)?","") ''
Regexp port :: Build in python will be nice :)
user1458574
source share