I am using PowerShell to work with the Java JRE configuration files such as deployment.config and deployment.properties. The file has parameters that refer to paths, but these paths contain escape characters in them. Here are a couple examples:
deployment.javaws.jre.0.location=http\://java.sun.com/products/autodl/j2se deployment.javaws.jre.0.path=C\:\\Program Files (x86)\\Java\\jre6\\bin\\javaw.exe
As you can see, Sun/Oracle is using a backslash (\) as an escape character and considers the colon (:) and backslash (\) as special characters to escape.
I want my script to be able to pull these paths and remove the escape character. So far, I've only figured out how to do it in two replaces:
$SysLevelConfigPath = ((Get-Content -Path "$env:SystemRoot\Sun\Java\Deployment\deployment.config |
Select-String "deployment.system.config=" |
Out-String).Trim().Split("=")[1] -replace "\\\\","\" -replace "\\:",":")
Is there way to do it in a single replace?