PowerShell: String Wildcards

By Xah Lee. Date: . Last updated: .

Wildcard can be used to represent string patterns. For example, dir "*jpg" means list any filename ending in jpg.

Wildcard Syntax

Match any character.
Match any character, zero or more times.
Match a range of characters a to z.
Match any char in chars

Operator for String Match Wildcard

str -like wildcard

return True if str match wildcard. else False. Case-insensitive

[see PowerShell: True/False (boolean)]

"mycat.jpg" -like "*jpg"
# True

# the wildcard must be on right side

Case-insensitive. Same as -Like.






Case-insensitive. Same as -NotLike.



PowerShell String