Tuesday, 10 September 2013

Regex pattern to match three different things

Regex pattern to match three different things

I need help to create 4 regex patterns to match 4 different things in a
block of text.
This is the block of text (the names are irrelevant):
[2013/8/27 - 20:44:3] AdmCmd: Damian Santos was fined $1000 by Scott
Parker, reason: BH(8-27-2013)
[2013/8/29 - 21:56:49] AdmCmd: Jimmy Greiner was fined $304389 by Scott
Parker, reason: LOL(8-29-2013)
[2013/8/29 - 22:4:54] AdmCmd: Jimmy Greiner has been jailed by Scott
Parker, reason: LOL(8-29-2013)
[2013/8/29 - 22:5:38] AdmCmd: Jimmy Greiner has been released from prison
by Scott Parker, reason: TS(8-29-2013)
[2013/8/29 - 22:42:55] AdmCmd: James McAdams has been released from prison
by Damian Santos, reason: test(8-29-2013)
[2013/8/30 - 20:17:23] AdmCmd: James McAdams has been released from prison
by Scott Parker, reason: TS(8-30-2013)
[2013/8/30 - 20:26:15] AdmCmd: James McAdams has been jailed by Jimmy
Greiner, reason: Test(8-30-2013)
[2013/8/30 - 20:26:37] AdmCmd: James McAdams has been released from prison
by Scott Parker, reason: Test(8-30-2013)
[2013/8/31 - 11:35:35] AdmCmd: Scott Parker was fined $5000 by Scott
Parker, reason: BH(8-31-2013)
[2013/8/31 - 11:36:0] AdmCmd: Scott Parker was fined $5000 by Scott
Parker, reason: BH(8-31-2013)
[2013/8/31 - 11:36:49] AdmCmd: Damian Santos was fined $5000 by Scott
Parker, reason: UNRP driving(8-31-2013)
I need to match the names who were: fined, released or jailed. I got a
pattern for this one already:
[A-Za-z ]+(?=was|has)
I need the name of the person who issued one of these actions (the names
near the end of each sentence). I tried to get a pattern for it, but I
can't exclude the "by" word:
(?=by)[A-Za-z ]+(?=,)
I didn't try a pattern for the reason (without the date) and the date,
which are both located at the end. I need them cut clean via a nice
pattern.
I would appreciate some help.
Thank you.

No comments:

Post a Comment