It doesn't make much sense to use regexps when they're clearly undesirable. They are pretty slow just to compile, and then you have to match them to your input string on top of that. Just do something like the link I posted; it has a much lower runtime than a regexp.