Backslashes in Powershell Backslashes in Powershell windows windows

Backslashes in Powershell


-split splits on a regex by default. So it is the regex that requires escaping a backslash. You can tell PowerShell not to use a regex like so:

$path -split '\',-1,'SimpleMatch'

-join is just taking whatever characters you supply to use as the delimiter to stick between the strings being joined.


-split is accepting a regular expression where backslash is special character, so it need to be escaped