Why is [\ W _] + with the modifier I in the Javascript regex matching i, k, s?

I forgot to delete the modifier I in the template, which should cross out non-alphanumeric characters:

str.replace(/[\W_]+/gi," "); 

And I thought that [\W_] would match i , k and with + quantifier even s : D

Without a modifier, I am working fine. And of course, the modifier I am a mistake, but I do not understand this strange behavior: regex101 and here is the fiddle

I am using Firefox 32.0.1

enter image description hereenter image description here

+5
source share
1 answer

This is a bug that affects Firefox 32.0 and 32.0.1.

It has already been fixed on Firefox 33 Beta.

+5
source

Source: https://habr.com/ru/post/1202550/


All Articles