regex help
-
יום שישי 02 מרץ 2012 22:31I've got a here-string with lots of emails in it that I want to pull out...how can I get all of them? \s(.+@.+)\sguessing that should be good enough but I cant recall how to do themultiline and multiple match bit...was going to just chop it up and do it the old fashioned way, but I figuredI'd use this as a chance to drill in more regex :)rob? :)
Justin Rich
http://jrich523.wordpress.com
PowerShell V3 Guide (Technet)
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
כל התגובות
-
יום שישי 02 מרץ 2012 22:48perhaps not the best pattern, but this worked..$reg = [regex]"\s([\d\w\.]+@.+?)\s"
Justin Rich
http://jrich523.wordpress.com
PowerShell V3 Guide (Technet)
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
יום שישי 02 מרץ 2012 23:01
One way:
$HereString | select-string -pattern '\b(\w+@\w+?\.\w+?)\b' -AllMatches
Another way:
([regex]::Matches($HereString,'\b(\w+@\w+?\.\w+)\b') | select -expand value)
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
- נערך על-ידי mjolinorMicrosoft Community Contributor יום שישי 02 מרץ 2012 23:16
- סומן כתשובה על-ידי Yan Li_Microsoft Contingent Staff, Moderator יום שני 05 מרץ 2012 06:21
-
יום שישי 02 מרץ 2012 23:06
This is the one that I use:
([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})
Rich Prescott | Infrastructure Architect, Windows Engineer and PowerShell blogger | MCITP, MCTS, MCP
Engineering Efficiency
@Rich_Prescott
Windows System Administration tool
AD User Creation tool -
יום שישי 02 מרץ 2012 23:25hmm was just using select-string, should have known that... thanks!
Justin Rich
http://jrich523.wordpress.com
PowerShell V3 Guide (Technet)
Please remember to mark the replies as answers if they help and unmark them if they provide no help.