I am trying to replace a sentence in .config file using powershell.
${c:Web.config} = ${c:Web.config} -replace
‘$BASE_PATH$\Test\bin`$Test_TYPE`$\WebTest.dll’ , ‘c:\program Files\example\webtest.dll’
Everytime I try to run the above code I get
“Invalid regular expression pattern:
$BASE_PATH$\Test\bin\$Test_TYPE$\WebTest.dll”
at c:\tests\runtesting.ps1 -replace
<<<<
$BASE_PATH$\Test\bin\$Test_TYPE$\WebTest.dll
If I don’t use the backtick the dollar signs will disappear and some text.
How would I pass dollar signs in a string to -replace?
This is about how to escape regexes. Every special character (special with regards to regular expressions) such as
$should be escaped with\The backtick would be used when the regex would be like this: