Warning Message in Logstash 8: Redundant Nested Repeat Operator in Regular Expression

grok { match => { "message" => "%{SPACE}?" } }

will result in the error message

warning: regular expression has redundant nested repeat operator * /(?:\s*)?/

SPACE will match zero or more whitespace characters, so the whitespace is optional. The ? or ()? is redundant and you can remove it in all four cases.

^foo%{SPACE}%{NUMBER:word} will match foo1, but note that ^foo%{SPACE}%{WORD:word} will not match foobar because WORD requires a word boundary at each end, and o is not a word boundary.

2 Likes