Reputation: 36
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.
Upvotes: 0
Views: 2439
Reputation: 785731
Since graylog2
is written in Java I believe lookarounds should work. Try this regex:
(?<=: )(.+?)(?=: |$)
Update: If you really need 4 different regex for 4 components then use:
RegEx 1:
(?<=: )(.+)(?=(?:: .+){3}[^:]*$)
RegEx 2:
: [^:]*: (.+?)(?=: )
RegEx 3:
: [^:]*: .+?: ([^:]+)
RegEx 4:
(?<=: )([^:]+)$
Upvotes: 3