【发布时间】:2021-11-09 10:50:41
【问题描述】:
我在 splunk 中的日志如下:
[ A=xaxxxxx ] [ B=weea case ] [ C=another example 0 ]
如何在“=”之后只获取方括号中的字符串
像这样:xaxxxxx; weea case ; another example 0
我的雷克斯是:rex field=_raw "(?<New_Field>\[\sC=(.*?)\s\])"
它提取所有内容,包括方括号 [...]。
【问题讨论】:
-
使用
\[\sC=(?<New_Field>[^\][]*)\s\]regex101.com/r/6PhHvy/1 -
(?<New_Field>(?<=\[ [A-Z]\=).*?(?= \]))regex101.com/r/mjgYhe/1(?<=\[ [A-Z]\=).*?(?= \])将只返回值,因此不需要名称。 regex101.com/r/QZdrFw/1