Fix #997: Limited support for in-pattern regex flags.

Have you checked whether this is properly inlined and optimized?