updated to solve @tmcw's observation about character classes