Question:
I am in the process of converting thousands of lines of batch code into PowerShell. I’m using regex to help with this process. The problem is part of the code is:
1 2 3 4 5 6 7 8 9 10 11 |
Question:
I am in the process of converting thousands of lines of batch code into PowerShell. I'm using regex to help with this process. The problem is part of the code is: $2 |
When replaced it just shows $2
and doesn’t expand out the variable. I’ve also used single quotes for the second portion of replace instead of escaping the variables, same result.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$origString = @' IF /I "%OPERATINGSYSTEM:~0,6%"=="WIN864" SET CACHE_OS=WIN864 ...many more lines of batch code '@ $replacedString = $origString -replace "(IF /I `"%)(.+)(:.+%`"==`")(.+`")(.+)","if ( Question:
I am in the process of converting thousands of lines of batch code into PowerShell. I'm using regex to help with this process. The problem is part of the code is:
Question:
I am in the process of converting thousands of lines of batch code into PowerShell. I'm using regex to help with this process. The problem is part of the code is: $2 |
When replaced it just shows $2
and doesn’t expand out the variable. I’ve also used single quotes for the second portion of replace instead of escaping the variables, same result.
$2 -match "^
$4 ) {`$5 }”
$replacedString