I have a file in which I need to modify a URL, not knowing what that URL contains, just like in the following example: In file file.txt I have to replace the URL, so that wether it is "https://SomeDomain/Release/SomeText" or "https://SomeDomain/Staging/SomeText" to "https://SomeDomain/Deploy/SomeText". So like, whatever is written between SomeDomain and SomeText, it should be replaced with a known String. Are there any regex that can help me achieve this?
I used to do it with the following command"
((Get-Content -path "file.txt" -Raw) -replace '"https://SomeDomain/Release/SomeText");','"https://SomeDomain/Staging/SomeText");') | Set-Content -Path "file.txt"
This works fine, but I have to know if in file.txt the URL contains Release or Staging before executing the command.
Thanks!