1 回答
TA贡献1815条经验 获得超13个赞
这应该可以解决问题:^\[(.*?)\](?:\[(.*?)\])?->([a-zA-Z ]+)。确保您使用的是多行标志。这是一个Python演示:
>>> for x in re.finditer(r'^\[(.*?)\](?:\[(.*?)\])?->([a-zA-Z ]+)', file, re.M):
print(x.group(1), x.group(2), x.group(3))
2018.07.10 00:30:03:109 TraceID: 8HRWSI105YVO91 IncomingTime
2018.07.10 00:30:03:109 TraceID: 8HRWSI105YVO91 IncomingData
2018.07.10 00:30:03:109 TraceID: 8HRWSI105YVO91 ThreadID
2018.07.10 00:30:03:109 TraceID: 8HRWSI105YVO91 RequestExecuteStart
2018.07.10 00:30:03:109 TraceID: 8HRWSI105YVO91 RequestInfo
2018.07.10 00:30:03:109 TraceID: 8HRWSI105YVO91 CheckUserInfo
2018.07.10 00:30:03:218 None Start RTS
2018.07.10 00:30:03:640 TraceID: 8HRWSI105YVO91 StartExecuteTask
2018.07.10 00:30:03:749 TraceID: 8HRWSI105YVO91 EndExecuteTask
2018.07.10 00:30:03:749 TraceID: 8HRWSI105YVO91 RequestExecuteEnd
2018.07.10 00:30:03:749 TraceID: 8HRWSI105YVO91 OutgoingData
您可以使用来只给您实际的跟踪ID ^\[(.*?)\](?:\[TraceID: (.*?)\])?->([a-zA-Z ]+)。
- 1 回答
- 0 关注
- 252 浏览
添加回答
举报