I have a regex string that gets the value from a CSS code like that
body {
background: #000;
}
/* drapeDecalage: 10px */
and I want to parse the commented drapeDecalage value.
For that I'm using regex, and I've made an expression like that:
(?<=\/\* drapeDecalage: )(.*?)(?=px \*\/)
which is perfectly working in PHP, but not in JavaScript, I've got this error
Uncaught SyntaxError: Invalid regular expression: /(?<=/* drapeDecalage: )(.*?)(?=px */)/: Invalid group
with this code:
var re = /(?<=\/\* drapeDecalage: )(.*?)(?=px \*\/)/;
var str = '/* drapeDecalage: 10px */';
console.log(re.exec(str));
Demo at Regex101 with PHP PCRE https://regex101.com/r/nL2yX9/2
JavaScript code demo at JSFiddle: https://jsfiddle.net/wd574aw3/
What's wrong? How to fix that?
Thanks