internet explorer 11 Syntax error in regular expression error with javascript RegExp

谁说我不能喝 提交于 2019-12-24 10:30:58

问题


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.



来源:https://stackoverflow.com/questions/46735209/internet-explorer-11-syntax-error-in-regular-expression-error-with-javascript-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!