Reputation: 3
lets say I har raw data thats like this
ERROR -- : FluentLogger: Can't convert to msgpack: (blah: blah: balh:.... ):
I want to capture
FluentLogger: Can't convert to msgpack:
currently I have this
(?>ERROR -- :)(?<msg1>.*):
but the problem with this is that it would capture
FluentLogger: Can't convert to msgpack: (blah: blah: balh:.... ):
how would I write the regex for that?
Upvotes: 0
Views: 96
Reputation: 11
One or more 'not :' by ':' use
[^:]+:
To find the first two of these in a string
/[^:]+:[^:]+:/
To capture the first two of these after ERROR -- : in a string
(?>ERROR -- :)(?[^:]+:[^:]+:)
Upvotes: 0
Reputation: 7627
You can do:
Note this is close to your original attempt:
(?>ERROR -- :)(?<msg1>.*):
but not quite, since you use ?>
for look behind, but it should have been (?<=
).
Upvotes: 0