Internet Explorer 11使用javascript RegExp的正则表达式错误中的语法错误 [英] internet explorer 11 Syntax error in regular expression error with javascript RegExp

查看:68
本文介绍了Internet Explorer 11使用javascript RegExp的正则表达式错误中的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Internet Explorer 11中收到一个Syntax error in regular expression错误,并且尝试了以下选项:

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

我很好奇我在这里想念的东西. [插入评论这在其他浏览器中如何正常工作]

解决方案

您正尝试使用带有unicode标志("u")的正则表达式,该标志 XRegExp 的库.

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]

解决方案

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.

这篇关于Internet Explorer 11使用javascript RegExp的正则表达式错误中的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆