Souladin
asked on
Getting multiple matches from a string with PowerShell
I have a bunch of log files that I'd like to parse through and pull string data out of, but the RegEx on this one is getting a little outside of my level of expertise. I'm basically going to use code similar to that found here :
What I really need help with is figuring out the RegEx for these log files. Here is an example of what they look like:
What I'm trying to match and pull out is the number inside the value="", the LASTNAME, FIRSTNAME and then I want the string between [ and @ (which may or may not contain a single period in it).
Are there any RegEx experts out there that can assist?
$input_path = 'c:\test\file.txt'
$regex = '' #Need help with this part
select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value }
What I really need help with is figuring out the RegEx for these log files. Here is an example of what they look like:
<option value="954393">LASTNAME1, FIRSTNAME1 - [lfirstname1@domain.com]</option>
<option value="819613">LASTNAME2, FIRSTNAME2 - [firstname2.lastname2@domain.com]</option>
<option value="1151900">LASTNAME3, FIRSTNAME3 - [firstname3.lastname3@domain.com]</option>
What I'm trying to match and pull out is the number inside the value="", the LASTNAME, FIRSTNAME and then I want the string between [ and @ (which may or may not contain a single period in it).
Are there any RegEx experts out there that can assist?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was way less complicated than I thought it would be. Looks like I need to take that regex refresher class again. Thanks!
Glad I could help!
You could read some answers and then answer a few questions here. Bet it would trump that introductory course :)
You could read some answers and then answer a few questions here. Bet it would trump that introductory course :)
Open in new window
You'll find the number in $1, the lastname in $2, the firstname in $3 and the last string in $4.HTH,
Dan