Splunk PCRE 组名称问题
我正在尝试在 PCRE 组名称中添加一个空格。不知道该怎么做。例如:
rex field=_raw "Time take = (?<"TimeInMillisecs">[^\s^\D+]+)
在上面,我需要组名称为“Time in Millisecs”。如何更改上面的表达式?
I am trying to add a space to the PCRE group name.Not sure how to do so.For ex:
rex field=_raw "Time taken = (?<"TimeInMillisecs">[^\s^\D+]+)
In the above,I need the group name to be "Time in Millisecs".How do I change the above expression?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不。使用 Splunk 字段名称中的空格可能会出现问题。最好使用压缩名称,然后在查询末尾使用
rename
命令更改为所需的显示名称。Don't. Working with spaces in Splunk field names can be problematic. It's best to use the compressed name and then use a
rename
command at the end of the query to change to the desired display name.正则表达式中的几个单词:
[^\s^\D+]+
匹配除空格、^
、非数字和+ 之外的一个或多个字符
字符。请注意,
\D
匹配任何空格、^
和+
字符,因为它们是非数字字符,因此[^\s^ \D+]+
等于[^\D]+
。正如您所看到的,“非数字字符之外的任何一个或多个字符”实际上与“一个或多个数字字符”相同。因此,为了使您的正则表达式没有歧义,您可以使用:
A couple of words on your regex:
[^\s^\D+]+
matches one or more chars other than whitespace,^
, non-digit and+
chars.Note that
\D
matches any whitespaces,^
and+
chars since they are non-digit chars, so[^\s^\D+]+
is equal to[^\D]+
. And as you can see, "any one or more chars other than non-digit chars" is actually the same as "one or more digit chars".So, to make your regex free from ambiguity, you can use: