[gfm mode] Fix exponential running time in regexp