my question is not about RegEx in general but about PhpStorm's search-replace-functionality with RegEx switched on.
I use PhpStorm and I want to use the dollar-sign in the replacing text.
But when I do that using RegEx mode then $ becomes the special char for identifying back references.
So I have to escape it.
But neither \$ nor $$ is accepted by PhpStorm.
How do I escape $ in RegEx-mode?
The \ is known as the escape code, which restore the original literal meaning of the following character. Similarly, * , + , ? (occurrence indicators), ^ , $ (position anchors) have special meaning in regex. You need to use an escape code to match with these characters.
You can escape dollar signs with a backslash or with another dollar sign. So $, $$, and \$ all replace with a single dollar sign.
How to use RegEx with . 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.
you have to use \\$
for the replacing text.
searching for $ is done with \$
.
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