O'Reilly logo

Mastering Windows PowerShell Scripting by Brenton J.W. Blawat

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

Regular expressions examples

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required