I am having difficulty matching strings in PowerShell that contain the pipe characters. Match returns true in the following scenario when it shouldn’t:
> "Debug|x86" -match "Debug|x128"
True
I have tried escaping the match argument pipe character, but this doesn’t change the unexpected result, e.g:
> "Debug|x86" -match "Debug`|x128"
True
It’s a regular expression so needs to be escaped with backslash, not PowerShell’s backtick, e.g.:
As it is a regular expression, If the pipe character is not escaped, it evaluates to “Debug or x128”.