Appendix B. Regular Expression Reference
Regular expressions play an important role in most text parsing and
text matching tasks. They form an important underpinning of the -split and -match operators, the switch statement, the Select-String cmdlet, and more. Tables B-1 through B-9 list commonly used regular
expressions.
Table B-1. Character classes: patterns that represent sets of characters
Character class | Matches |
|---|---|
| Any character except for a newline. If the regular
expression uses the PS > "T" -match '.' True |
| Any character in the brackets. For example: PS > "Test" -match '[Tes]' True |
| Any character not in the brackets. For example: PS > "Test" -match '[^Tes]' False |
| Any character between the
characters PS > "Test" -match '[e-t]' True |
| Any character not between any of
the character ranges PS > "Test" -match '[^e-t]' False |
| Any character in the Unicode group or block range
specified by PS > "+" -match '\p{Sm}'
True |
| Any character not in the Unicode
group or block range specified by PS > "+" -match '\P{Sm}'
False |
| Any word character. Note that this is the Unicode definition ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access