You could do a trivial regex that combines those two:
pat = re.compile('foo|bar')
if pat.match(mystring):
# Do whatever
You could then expand the regex to do whatever you need to, using the |
separator (which means or in regex syntax)
Edit: Based upon your recent edit, this should do it for you:
pat = re.compile('(foo|bar)\.trailingString');
if pat.match(mystring):
# Do Whatever
The []
is a character class. So your [foo|bar]
would match a string with one of the included characters (since there's no * or + or ? after the class). ()
is the enclosure for a sub-pattern.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…