-
Notifications
You must be signed in to change notification settings - Fork 0
REGEX
neztach edited this page Aug 31, 2023
·
1 revision
A regular expression is a pattern used to match text. It can be made up of literal characters, operators, and other constructs.
| Code | Explanation |
'Trevor' -match '^T\w*' |
Perform a regular expression match against a string value. # Returns $true and populates $matches variable |
$matches[0] |
Returns 'Trevor', based on the above match |
@('Trevor', 'Billy', 'Bobby') -match '^B' |
Perform a regular expression match against an array of string values. Returns Billy, Bobby |
$regex = [regex]'(\w{3,8})'
$regex.Matches('Trevor Bobby Dillon Joe Jacob').Value |
Find multiple matches against a singleton string value. |
neztach - PowerShell Public repo