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.

Share Improve this question edited Feb 8, 2018 at 2:13 Ron Ross asked Feb 8, 2018 at 1:27 Ron RossRon Ross 2854 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

Only Google Chrome supports lookbehind ?<!

So replacing (?<!-) with [^-] should do the trick.

本文标签: