PowerShell: String Wildcards
Wildcard represents string patterns.
e.g. *jpg
means text ending in jpg
- PowerShell: Path parameter value is interpreted as wildcard pattern.
- If you don't want wildcard, use the parameter
LiteralPath
.
Wildcard Syntax
?
-
Match any character.
*
-
Match any character, zero or more times.
[a-z]
-
Match a range of characters a to z.
[chars]
-
Match any char in chars
Operator for String Match Wildcard
str -like wildcard
-
- return True if str match wildcard. else False.
- Case-insensitive
"mycat.jpg" -like "*jpg" # True # the wildcard must be on right side
-iLike
-
Case-insensitive. Same as
-Like
. -cLike
-
Case-sensitive
-notLike
-
Negation.
-iNotLike
-
Case-insensitive. Same as
-NotLike
. -cNotLike
-
Case-sensitive
PowerShell, string and regular expression
- PowerShell: String
- PowerShell: Single Quoted String
- PowerShell: Double Quoted String
- PowerShell: Here-String
- PowerShell: Escape Characters
- PowerShell: String Length
- PowerShell: Join String
- PowerShell: Split String
- PowerShell: Format String
- PowerShell: String Methods
- PowerShell: String Wildcards
- PowerShell: Regular Expression Operators
- PowerShell: Regex Result ($Matches)
- PowerShell: Regular Expression Syntax