Regex 使用Splunk中的rex命令创建正则表达式以返回xml子元素
我试图使用Splunk命令rex,它使用正则表达式从日志语句中提取数据。这是xml的重要部分:Regex 使用Splunk中的rex命令创建正则表达式以返回xml子元素,regex,xml,splunk,Regex,Xml,Splunk,我试图使用Splunk命令rex,它使用正则表达式从日志语句中提取数据。这是xml的重要部分: <tmsTrip xmlns="removed_for_security" xmlns:ns2="removed_for_security"> <recordType>PURCHASEDLINEHAUL</recordType> <eventType>DISPATCH</eventType> <updatedDateG
<tmsTrip xmlns="removed_for_security" xmlns:ns2="removed_for_security">
<recordType>PURCHASEDLINEHAUL</recordType>
<eventType>DISPATCH</eventType>
<updatedDateGMT>2020-05-21T17:22:55.000Z</updatedDateGMT>
<origin>
<ns2:numberCode>923</ns2:numberCode>
<ns2:numberType>2</ns2:numberType>
</origin>
<destination>
<ns2:numberCode>72</ns2:numberCode>
<ns2:numberType>2</ns2:numberType>
</destination>
购买的长途运输
派遣
2020-05-21T17:22:55.000Z
923
2.
72
2.
我需要来源地和目的地的数字代码。
这只雷克斯返回第一只,923
rex field=_raw "\<ns2\:numberCode\>(?P<origin>[^\<]+)"
rex field=\u raw”\(?P[^\您可以告诉
rex
使用max\u match
选项返回这两个字段
| rex max_match=0 "\<ns2\:numberCode\>(?P<origin>[^\<]+)"
| eval originCode = mvindex(origin, 0), destCode = mvindex(origin, 1)
rex max\u match=0”\(?P[^\您可以告诉
rex
使用max\u match
选项返回这两个参数
| rex max_match=0 "\<ns2\:numberCode\>(?P<origin>[^\<]+)"
| eval originCode = mvindex(origin, 0), destCode = mvindex(origin, 1)
| rex最大匹配=0”\(?P[^\WOW!谢谢工作得很好!我试过使用spath和xpath。我想配置没有为它们设置,我无法更改。但是你的工作很出色!!!再次感谢!哇!谢谢工作得很好!我试过使用spath和xpath。我想配置没有为它们设置,我无法更改。但是你的工作很出色!!!谢谢再一次!