On Friday, 29 March 2013, Alain Ketterlin wrote: > Victor Hooi <victorh...@gmail.com <javascript:;>> writes: > > > expression1 = re.compile(r'....') > > expression2 = re.compile(r'....') > [...] > > Just a quick remark: regular expressions are pretty powerful at > representing alternatives. You could just stick everything inside a > single re, as in '...|...' > > Then use the returned match to check which alternative was recognized > (make sure you have at least one group in each alternative). > > Yes, and for extra ease/clarity you can name these alternatives ( '(?P<name>pattern)'). Then you can do
if m.group('case1'): ... elif m.group('case2'): ... -- Arnaud
-- http://mail.python.org/mailman/listinfo/python-list