Fix regex encoding errors with recent ruby versions