-2

I am not able to match a pattern in logstash grok. Here is my data:

some words key[value]some words in between key[value] key[value]....some more words

I want to match a pattern

key[value] key[value]

i.e. two consecutive key values with space in between

I tried with (?=\w+[.*])\s(?=\w+[.*]), but it's not working.

I am getting the entire line with the very first key[value] and not from key[value] key[value].

Emma
  • 27,428
  • 11
  • 44
  • 69
Ravi
  • 21
  • 1

2 Answers2

0

I'm guessing that positive lookahead is unnecessary and this expression might work:

[A-Za-z0-9]+\[[A-Za-z0-9]+\]\s[A-Za-z0-9]+\[[A-Za-z0-9]+\]

DEMO 1

Or:

(?<=[^a-z])\s(\S+\[[^]]+\])

DEMO 2

Emma
  • 27,428
  • 11
  • 44
  • 69
0
\S+\[[^\[]+\]

Means any non-space character follows by [, follows by any character except [ which repeat more than one time and follows by ]

Demo

Hamed Ghasempour
  • 435
  • 3
  • 12