I want to replace
#{account_nbr}
with
{{account_nbr}}
in the find, I tried this:
\#\{()\w+\1\}
and in the replace, this:
{{\$1}}
The find seems to work but I can't get the backreference correctly.
What's wrong?
replace in JavaScript. To use RegEx, the first argument of replace will be replaced with regex syntax, for example /regex/ . This syntax serves as a pattern where any parts of the string that match it will be replaced with the new substring. The string 3foobar4 matches the regex /\d.
If you are having a string with special characters and want's to remove/replace them then you can use regex for that. Use this code: Regex. Replace(your String, @"[^0-9a-zA-Z]+", "")
You do not need any backreferences the way you are using them.
This is the regex you can use:
\#\{(\w+)\}
Replacement should be
{{$1}}
When you use \$
, a literal $
is used, not the actual back-reference.
Regex demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With