This regular expression is re-compiled every invocation of the function.

IMHO it's better to promote this to be a constant in the module namespace, so it's compiled only once.