Simplify regular expression code