improve regex

Character classes are cheaper than "|" and non-capturing groups are better than capturing groups when captures aren't needed.