我有一个问题是从我的正则表达式中获取空间。谁能帮助我使用键值机制提供正确的正则表达式。请注意,键值位置可能会改变而不是固定的。
正则表达式
\s*([\w\d_]*)=(.*?)\s+
输入
spt=38271 deviceExternalId=SUKUK node 1 dst=99.111.185.141 app=HTTPS rt=Jan 23 2013 15:30:45 deviceFacility=Packet filter msg=Connection was reset by server destinationTranslatedPort=443
我的结果
Match 1: spt=38271
Subgroups:
1: spt
2: 38271
Match 2: deviceExternalId=SUKUK
Subgroups:
1: deviceExternalId
2: SUKUK
Match 3: dst=99.111.185.141
Subgroups:
1: dst
2: 99.111.185.141
Match 4: app=HTTPS
Subgroups:
1: app
2: HTTPS
Match 5: rt=Jan
Subgroups:
1: rt
2: Jan **==>Should grab [Jan 23 2013 15:30:45]**
Match 6: deviceFacility=Packet
Subgroups:
1: deviceFacility
2: Packet **==>Should grab [Packet filter]**
Match 7: msg=Connection
Subgroups:
1: msg
2: Connection **==>Should grab [Connection was reset by server]**
Match 8: destinationTranslatedPort=443
Subgroups:
1: destinationTranslatedPort
2: 443