internet explorer 11 Syntax error in regular expre

2019-07-27 02:54发布

问题:

I am receiving a Syntax error in regular expression error in Internet Explorer 11 and I have tried the following options:

chars = text.split(/(?!$)/u),
chars = text.split(new RegExp("(?!$)", 'u'))
chars = text.split(new RegExp('/(?!$)/', 'u'));

I am curious what I am missing here. [insert comment how this works fine in other browsers]

回答1:

You are trying to use a regular expression with the unicode flag ("u") which is not supported by any Internet Explorer <= 11.

You can try to use a library like XRegExp.