admin管理员组文章数量:1287088
The following code snippet is causing Internet Explorer to throw an Unexpected Quantifier error, but Google chrome is working just fine.
var regexWord = new RegExp("\\b(?<!-)"+lWord+"\\b(?!-)");
How to fix this so it works cross browser?
UPDATE
After some testing it appears the error is a result of (?<!-)
in the regex pattern. Though, still not sure how to fix it. Seems like it is correct based on the regex documentations I've read.
The following code snippet is causing Internet Explorer to throw an Unexpected Quantifier error, but Google chrome is working just fine.
var regexWord = new RegExp("\\b(?<!-)"+lWord+"\\b(?!-)");
How to fix this so it works cross browser?
UPDATE
After some testing it appears the error is a result of (?<!-)
in the regex pattern. Though, still not sure how to fix it. Seems like it is correct based on the regex documentations I've read.
1 Answer
Reset to default 11Only Google Chrome supports lookbehind ?<!
So replacing (?<!-)
with [^-]
should do the trick.
本文标签:
版权声明:本文标题:regex - JavaScript Unexpected Quantifier Error in Internet Explorer, but works in Google Chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741306678a2371407.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论