E-mail-Address-Extractor via RegEx

Regular expressions are extremely powerful - and complex. Fortunately, there are plenty of sources for good regular expressions that describe all kinds of patterns. This is how you turn a RegEx pattern into a regular expression engine:

$regex = [RegEx]'(?i)\s[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\s'

$regex now is a highly specialized filter for extracting e-mail addresses from text. Use this to list all emails in $text:

$regex.Matches($text) | Select-Object -ExpandProperty Value

Posted Jun 23 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.