Avoid to compile regex several times

A (very) small improvement to avoid compiling the regex each time.