Skip to content Skip to sidebar Skip to footer

Why Does JavaScript RegExp Lack The "s" Flag?

I love Regular Expressions. However, I've just now come across the inability to use the s flag when running JavaScript RegExp in the browser. I'm curious as to why is this flag not

Solution 1:

There was no big logic to it, it just wasn't included, like lots of other regex features other environments have that JavaScript doesn't (so far).

It's in the process of being added now. Currently Stage 3, so maybe ES2018, maybe not Stage 4 as of Dec 2017 so will be in ES2018, but odds are high and you'll see support being added to cutting-edge browsers this year ASAP.

(Look-behind and unicode property escapes are also on the cards...)


Side note:

When I run this on regex101.com they support the s flag...

Not if you set the regex type to JavaScript via the menu. Click the menu button in the top left:

enter image description here

...and change the "flavor" to JavaScript:

enter image description here

You probably left it on its default, which is PCRE, which does indeed support the s flag.

They used to make this more obvious. Since they hid it away on a menu, you're not remotely the first person I've seen not have it set right...


Post a Comment for "Why Does JavaScript RegExp Lack The "s" Flag?"