Regular Expressions
You can use regular expressions (regex) to perform searches against a text. For the uninitiated, anything but a trivial regular expression can be a confusing mess. To make the topic more difficult, regular expressions differ slightly across different programming languages, platforms, and tools. Given that PowerShell is built on .NET, PowerShell uses .NET-style regular expressions. There are often several different ways to achieve a goal when using regular expressions.
This chapter covers the following topics:
- Regex basics
- Anchors
- Quantifiers
- Character classes
- Alternation
- Grouping
- Look-ahead and look-behind
- The .NET Regex type
- Regex options
- Examples of regular expressions
Regular expressions can be complex, but knowing a small set of basic characters provides a useful foundation to build upon.