我需要帮助来创建 4 个正则表达式模式来匹配文本块中的 4 个不同的东西。
这是文本块(名称无关紧要):
[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)
我需要匹配以下姓名:罚款、释放或入狱。我已经有了这个模式:
[A-Za-z ]+(?=was|has)
我需要发出这些行动之一的人的姓名(每个句子末尾附近的姓名)。我试图为它找到一个模式,但我不能排除“by”这个词:
(?=by)[A-Za-z ]+(?=,)
由于原因(没有日期)和日期,我没有尝试模式,它们都位于末尾。我需要通过漂亮的图案将它们切割干净。
我会很感激一些帮助。
谢谢你。