0

I try to regex the following string

 : hostname: Oct 16 03:49:39.515: %BLA: message

and want to get the strings between the ": " and the last string after the last ": "

when I use : (.+?): I get hostname.

Unfortenately I am not able to get Oct 16 03:49:39.515, %BLA and message. I need single regex for every substring, I don't want to have them all in one.

sbstnmrwld
  • 36
  • 5

1 Answers1

3

Since graylog2 is written in Java I believe lookarounds should work. Try this regex:

(?<=: )(.+?)(?=: |$)

RegEx Demo


Update: If you really need 4 different regex for 4 components then use:

RegEx 1:

(?<=: )(.+)(?=(?:: .+){3}[^:]*$)

RegEx 2:

: [^:]*: (.+?)(?=: )

RegEx 3:

: [^:]*: .+?: ([^:]+)

RegEx 4:

(?<=: )([^:]+)$
anubhava
  • 761,203
  • 64
  • 569
  • 643