Regular expressions examples
When you are developing scripts, there will be many instances where you may want to use regular expressions. This section will explore regular expressions that you may run into in your environment. Since there are many methods to creating regular expressions, these are to be used as suggested starting points for your scripts.
The following diagram shows how to evaluate a MAC Address:
To test a MAC address against a regular expression, use this syntax:
"00:a0:f8:12:34:56" -match "^([0-9a-f]{2}:){5}[0-9a-f]{2}$"
The output of this is shown in the following screenshot:
The preceding example shows how to create a regular expression ...
Get Mastering Windows PowerShell Scripting 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.