Regex 请求:协助Splunk-Rex查询

Regex 请求:协助Splunk-Rex查询,regex,splunk,rex,Regex,Splunk,Rex,我在rex查询中遇到了一些问题,其中一位数字的日期呈现不正确的结果,而两位数字的日期提供正确的结果 以下是我正在查询的日志条目: Mar 7 14:24:29 10.52.176.215 Mar 7 12:24:29 963568 - Melbourne details-cable-issue - vdvfvfv Mar 20 09:52:55 10.52.176.215 Mar 20 07:52:55 963569 - Brisbane cable-issue 以下是查询: ^(?:[

我在rex查询中遇到了一些问题,其中一位数字的日期呈现不正确的结果,而两位数字的日期提供正确的结果

以下是我正在查询的日志条目:

Mar  7 14:24:29 10.52.176.215 Mar  7 12:24:29 963568 - Melbourne details-cable-issue - vdvfvfv

Mar 20 09:52:55 10.52.176.215 Mar 20 07:52:55 963569 - Brisbane cable-issue
以下是查询:

^(?:[^ \n]* ){7}(?P<extension>[^ ]+)[^\-\n]*\-\s+(?P<location>\w+)
^(?:[^\n]*){7}(?P[^]+)[^\-\n]*\-\s+(?P\w+)
对于Mar 7条目,我的查询给了我组扩展名“7”,而我的Mar 20条目给了我组扩展名“963569”,这是正确的

有人能解释一下我关于确认一位数和两位数日期的问题吗#7比20


谢谢大家:)

在第一个字符串中有几个连续的空格(它们看起来像填充空格),由于您在
(?:[^\n]*)中只匹配了一个空格
您会得到不匹配的结果

我建议在第一组中匹配1个或多个空格,并调整限制量词:

^(?:[^ \n]* +){5}(?P<extension>[^ ]+)[^-\n]*-\s+(?P<location>\w+)
            ^  ^
^(?:[^\n]*+){5}(?P[^]+)[^-\n]*-\s+(?P\w+)
^  ^