RegExps that don't modify global state?

Domenic Denicola domenic at
Tue Sep 16 11:16:04 PDT 2014

I had a conversation with Jaswanth at JSConf EU that revealed that RegExps cannot be used in parallel JS because they modify global state, i.e. `RegExp.$0` and friends.

We were thinking it would be nice to find some way of getting rid of this wart. One idea would be to bundle the don't-modify-global-state behavior with the `/u` flag. Another would be to introduce a new flag to opt-out. The former is a bit more attractive since people will probably want to use `/u` all the time anyway. I imagine there might be other possibilities others can think of.

I also noticed today that the static `RegExp` properties are not specced, which seems at odds with our new mandate to at least Annex B-ify the required-for-web-compat stuff.

More information about the es-discuss mailing list