Forum Discussion
nancyvargas
Dec 21, 2022Copper Contributor
Powershell - string replacement using regex
Hi All, I need help in powershell string replacement using regex. I need to replace a decimal value after a specific string pattern with a new decimal value stored in a variable. Like, in the entir...
jarleosmund
Dec 21, 2022Copper Contributor
$string = "This is a string with multiple Version=xxx values that need to be replaced."
$newValue = "3.14"
# Replace all occurrences of "Version=xxx" with the new value
$string -replace "Version=xxx", "Version=$newValue"
Got it from OpenAI's chatGBT 🙂