9
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 ...
Get Mastering PowerShell Scripting - Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.