PowerShell: Regular Expression Operators
String Match by Regex
-match
-
String matches regex pattern. Case-insensitive
"mycat.jpg" -match "\.+jpg" # the regex must be on right side
-iMatch
-
Case-insensitive. Same as
-Match
. -cMatch
-
Case-sensitive
-notMatch
-
Negation.
-iNotMatch
-
Case-insensitive. Same as
-Notmatch
. -cNotMatch
-
Case-sensitive
String Regex Replace
-Replace
-
Replaces strings matching a regex pattern. Case-Insensitive.
"wonderland" -replace "wonder", "lala" # result # lalaland
-iReplace
-
Case-insensitive. Same as
-Replace
. -cReplace
-
Case-sensitive
Escape Regex Meta Characters
[Regex]::Escape()
-
escape regex meta characters. Useful when a command or operator that takes regex, but you need plain text search.
PowerShell String
- PowerShell: Quote String
- PowerShell: Double Quoted String, String Expansion
- PowerShell: Here-String
- PowerShell: Escape Characters
- PowerShell: String Operators
- PowerShell: Join String
- PowerShell: Split String
- PowerShell: Format String
- PowerShell: String Methods
- PowerShell: String Wildcards
- PowerShell: Regular Expression Operators
- PowerShell: Regular Expression Syntax