Escaping text in regular expressions (RegEx) patterns

by Apr 19, 2011

Some PowerShell operators, such as –match, expect regular expressions. If you just want to match plain text, you will need to escape any special regular expressions character in your text. Let RegEx handle it for you rather than doing that manually:

PS > [Regex]::Escape("c:\windows")

 

c:\\windows

 

 

Twitter This Tip!
ReTweet this Tip!