Summary
In this chapter, we have taken a look at regular expressions and their use in PowerShell.
The Regex basics section introduce a number of heavily used characters. Anchors showing how the start and end of a string or a word boundary may be used to restrict the scope of an expression.
Character classes were introduced as a powerful form of alternation, providing a range of options for matching a single character. Alternation was demonstrated using different sets of expressions to be evaluated.
We looked at repetition using "*"
, +
, ?
, and curly braces and discussed the notion of greedy and lazy.
Grouping was introduced as a means of limiting the scope of alternation to repeat larger expressions or to capture strings.
Finally, a number of examples were included, bringing together the areas covered in this chapter to solve specific problems.
In Chapter 11, Files, Folders and the Registry, working with files, folders, and registry will be discussed.