Regex works on browser but not in Node.js

前端 未结 2 868
误落风尘
误落风尘 2021-01-20 20:09

I have a regex: /(?/g. Works fine in browser console if I do \"(<> * * * <

2条回答
  •  萌比男神i
    2021-01-20 20:45

    As an answer as well (more space):
    Unless node.js uses it's own regex engine and not the JavaScript one, lookbehinds are not supported in JS, thus (? cannot work. To somewhat mimic this feature from other programming languages, have a look at Flagrant Badassery or use additional packages like node-re2 or node-perl-regex.

    As for the differences between Browsers, Chrome does support lookbehinds.

提交回复
热议问题