- PowerShell Tutorial
- PowerShell - Home
- PowerShell - Overview
- PowerShell - Environment Setup
- PowerShell - Cmdlets
- PowerShell - Files and Folders
- PowerShell - Dates and Timers
- PowerShell - Files I/O
- PowerShell - Advanced Cmdlets
- PowerShell - Scripting
- PowerShell - Special Variables
- PowerShell - Operators
- PowerShell - Looping
- PowerShell - Conditions
- PowerShell - Array
- PowerShell - Hashtables
- PowerShell - Regex
- PowerShell - Backtick
- PowerShell - Brackets
- PowerShell - Alias
- PowerShell Useful Resources
- PowerShell - Quick Guide
- PowerShell - Useful Resources
- PowerShell - Discussion
Powershell - Regular Expression - Match Characters
Following is the example of supported regular expression characters in Windows PowerShell
#Format value #Matches exact characters anywhere in the original value. "book" -match "oo" #Format . #Logic Matches any single character. "copy" -match "c..y" #Format [value] #Logic Matches at least one of the characters in the brackets. "big" -match "b[iou]g" #Format [range] #Logic Matches at least one of the characters within the range. The use # of a hyphen (-) allows you to specify an adjacent character. "and" -match "[a-e]nd" #Format [^] #Logic Matches any characters except those in brackets. "and" -match "[^brt]nd" #Format ^ #Logic Matches the beginning characters. "book" -match "^bo" #Format $ #Logic Matches the end characters. "book" -match "ok$" #Format * #Logic Matches any instances of the preceding character. "baggy" -match "g*" #Format ? #Logic Matches zero or one instance of the preceding character. "baggy" -match "g?"
Output of all the above commands is True.
powershell_regex.htm
Advertisements