simplify regular expression matching