Gather info repeated 'N' times

1 view
Skip to first unread message

cccwebs

unread,
Jun 12, 2009, 11:14:05 AM6/12/09
to Regex
Hello,

I am relatively new to regex. What I am trying to do is parse a list
of info like this:

User: dwilliams
Date: 06-06-2009
Time: 12:00
Player: Dick Williams
Player: Tom Mathis
Player: Ed Davis
Player: Fred Masterson

This info is coming to me via email. Each of the initial entries are
fixed, User, Date, and Time. The Player entries could be any number
greater than 1. I need to be able to pull the player info into an
array or list so that I can act on each name independently. I can
make it pull out each piece separately but I don't know how to make it
go down the list to an indeterminate end.

Any help is appreciated!

cccwebs

Accmailer

unread,
Jun 22, 2009, 7:45:14 AM6/22/09
to Regex
Here is what i suggest, it is a two step solurion

ther regex is
^user:\x20([^\r\n]+)\r\ndate:\x20([^\r\n]+)\r\ntime:\x20([^\r\n]+)\r\n
((Player:\x20([^\r\n]+)\r\n)*)

sorry if the above gets broken into multiple lines :) it is not me!

apply it and collect $1,$2,$3,$4 variables

and here comes the 2nd step: delete all occurencies of "player: " and
line breaks as well from the 4th variable

And you are ready!

--
regards, Eugeny

P.S. If unclear, email me personally
Reply all
Reply to author
Forward
0 new messages