Regular Expressions with -match in PowerShell
📖 Scenario: You work in a small company and need to filter a list of email addresses to find only those from a specific domain.
🎯 Goal: Build a PowerShell script that uses the -match operator with a regular expression to find email addresses ending with @example.com.
📋 What You'll Learn
Create a list of email addresses in a variable called
emails.Create a regular expression pattern variable called
pattern to match emails ending with @example.com.Use a
foreach loop to check each email with -match and collect matching emails in a list called matchedEmails.Print the list of matched emails.
💡 Why This Matters
🌍 Real World
Filtering email lists is common in marketing, IT, and customer support to target or exclude specific groups.
💼 Career
Knowing how to use regular expressions with PowerShell helps automate text processing tasks in system administration and data management roles.
Progress0 / 4 steps