print '[Mm]atrix' or '[Mm]atrices'
import re for s in ('matrix', 'Matrix', 'matrics', 'Matrics'): print re.match(r'[mM]atrix|[mM]atrics', s) is not None
True True True True