【发布时间】:2019-07-21 11:27:27
【问题描述】:
我正在尝试解析下面的日志文件;但是,在所有“Step=Number”之后,我有点难以弄清楚如何匹配结果。
Step=10 , Step=11 , Step=12 , Step=13 , Step=14 , Step=15 , Step=16 , Step=18 , Step=17 , Step=20 , Step=19 , Step=25 , Step=21 , Step=26 , Step=28 , Step=24 , Step=22 , Step=23 , Step=27 , Step=30 , Step=29 , Step=35 , Step=34 , Step=32 , Step =31 , 步=38 , 步=37 , 步=36 , 步=50 , 步=45 , 步=48 , 步=41 , 步=52 , 步=42 , 步=57 , 步=65 , 步=61 , Step=62 , Step=64 , Step=54 , Step=53 , Step=59 , Step=63 , Step=84 , Step=71 , SelectedAuthenticationIdentityStores=paddedvalue, NetworkDeviceName=exampledevice, NetworkDeviceGroups=Update Source:All Sources:ACS , NetworkDeviceGroups=设备类型:所有设备类型:无线, NetworkDeviceGroups=位置:所有位置, ServiceSelectionMatchedRule=Rule-1, IdentityPolicyMatchedRule=Default
我在考虑组合后的匹配:\d\s\,\s
理想的目标是满足以下条件:
SelectedAuthenticationIdentityStores=paddedvalue, NetworkDeviceName=exampledevice, NetworkDeviceGroups=Update Source:All Sources:ACS, NetworkDeviceGroups=Device Type:All Device Types:Wireless, NetworkDeviceGroups=Location:All Locations, ServiceSelectionMatchedRule=Rule-1, IdentityPolicyMatchedRule=Default
p>
我尝试了以下正则表达式:\d\s\\,\s(.*),但它匹配第一个 Step=Number (Step=10) 之后的所有内容
【问题讨论】:
-
(?: ?Step=\d+ ,)*\s(.*)好吗? -
/(Step=\d+\s*,\s*)+(.*)/应该这样做。\2会给你想要的字符串。 -
如何将
(Step=\d+\s,\s)模式一无所有,这样你就可以轻松获取字符串的最后一部分?