A Practical Guide for Using Regex in PowerShell
Regular Expressions is often referred to as wizardry or magic and for that reason I stayed away from it for most of my career. I used it only when I had to and most of the time just reused examples that I found online. There’s nothing wrong with that of course, but I never took the time to learn it. I thought it was reserved for the elite. Turns out that it’s not that complicated and that I had been using it for years without knowing it.
In an effort to shorten the learning curve for others and to show you the value of learning regular expression I’ve written a blog post titled A Practical Guide for Using Regex in PowerShell. It will walk you through how to use regular expression in PowerShell and gives you a glimpse into how powerful regular expression is.
Below is an example of how to use regular expression to extract a user’s name from their distinguished name in Active Directory. To learn more check out this blog post.
Topics Covered
- -match operator
- -match operator with regular expression metacharacters
- -notmatch with where-object
- -replace operator
- -split operator
- Select-String
- Switch Statements
- Regex Object
Related Articles
Media Sync: Organize Your Photos and Videos with PowerShell
Do you have photos and videos that you have taken over the years that are scattered all over the place? Do you want to have …
Read moreNetNeighbor Watch: The PowerShell Alternative To Arpwatch
In this post, we are going to setup NetNeighbor Watch on a Raspberry Pi. NetNeighbor Watch can keep an eye on your network …
Read moreCreating a PowerShell Module to Improve Your Code
Do you have PowerShell code that you reuse in your scripts over and over? Do you have server names hard coded in variables? …
Read more