I am writing a powershell script to edit multiple text files. All the text files have a line like so
serverUrl=http://localhost:1234
The last 4 numbers vary in each file, but I need to change them all to 9090. I had tried using powershell wildcards like so:
foreach ($file in $files) {
(Get-Content $file).replace('serverUrl=http\://localhost\:????', 'serverUrl=http\://localhost\:9090') | Set-Content $file
}
But these didn't work unfortunately. Is there any way to do this? Thank you
Use the
-replaceregex operator instead of theString.Replace()method: