I'm trying to use regex in a Nodejs app. I usually use it in Python and it seems to have some differences.
Here is the problem :
I have this string \newcommand{\hello}{@replace}
and I want to replace @replace
by REPLACED
in the second curly bracelets ONLY when I found \hello
in the first curly bracelets. So the expected result is : \newcommand{\hello}{REPLACED}
I try this:
r = new RegExp('\\newcommand{\\hello}{(.*?)}');
s = '\\newcommand{\\hello}{@replace}';
s.replace(r, 'REPLACED');
But nothing is replaced... any clue?