Node JS PCRE regex and transforms support
<p>I've a need to apply a lot of PCRE regexes with multiple backreferences and apply perl style transforms <code>s/\/\/(\d+)/$1/s</code> in a Node JS app.</p>

<p>I searched around and found these two libraries for this purpose:</p>

<p><a href="https://github.com/mscdex/node-pcre" rel="nofollow">https://github.com/mscdex/node-pcre</a> (Regex application)</p>

<p><a href="https://github.com/tokuhirom/node-perl" rel="nofollow">https://github.com/tokuhirom/node-perl</a> (Perl style transforms)</p>

<p>I'm getting a lot of NPM errors during installation of these modules in Node v5.9.0. </p>

<p>The node-pcre library has an <a href="https://github.com/mscdex/node-pcre/issues/13" rel="nofollow">issue</a> which says the library stops working after NodeJS 0.10 version due to change in V8 API</p>

<p>I ran into installation issues for node-perl library as well.</p>

<p>Is there a way for me to get support for PCRE regexes and transforms in Node v5.9.0</p>

<p>Thanks</p>

<p>EDIT: One of the comments below was to specify a PCRE regex that am trying which does not work in javascript. Here's the example:</p>

<pre><code>var fs = require("fs");

var regex = '&lt;input type=\"hidden\"\s*name=\"itemId\"\s*value=\"(?P&lt;sku&gt;[\w\-]+)\"[^&lt;]*&gt;.*?&lt;SCRIPT LANGUAGE=\'JavaScript\'[^&lt;]*&gt;.*?(\g{sku}Matrix\s*\=.*?&lt;\/SCRIPT&gt;)';
var page = fs.readFileSync("./page.html");

var re = new RegExp(regex);
var matchStr = "";

matchStr = page.replace(re, function (match, $1) { return $1; });
console.log(matchStr);
</code></pre>

<p><strong>Response</strong></p>

<pre><code>SyntaxError: Invalid regular expression: /&lt;input type="hidden"s*name="itemId"s*value="(?P&lt;sku&gt;[w-]+)"[^&lt;]*&gt;.*?&lt;SCRIPT LANGUAGE='JavaScript'[^&lt;]*&gt;.*?(g{sku}Matrixs*=.*?&lt;/SCRIPT&gt;)/: Invalid group
    at new RegExp (native)
    at Object.&lt;anonymous&gt; (/home/user/project/abc.js:7:10)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:142:18)
    at node.js:939:3
</code></pre>