I have a text file and want to regex/replace something with the content of a variable in PowerShell.
- File:
my.json - Variable in Powershell
$version - Search for:
version : "something" - Replace
"something"with the content of the variable$version
Here is what I tried. Search and replace works as expected but the result is
version : "$version".
(Get-Content my.json) -replace '(?<pre>"version"[\s]*:[\s]*)(?<V>"[^\"]*")', '$1"$version"' | Out-File my.json