be more careful about mismatched regular expressions