regexregex-grouprsyslog

Need guidance in delimiter for regex


Trying to send multiline Kafka log from RSYSLOG to FLuentd.

(?<date>\[.*?\]) (.*?) ((.|\n*)*)

Here is the link: https://regex101.com/r/iFHyTi/1

But my regex is considering next timestamp pattern as a single line. Requirement is to stop before the next timestamp starts.


Solution

  • You can match all subsequent lines that start with either a TAB or a space char:

    (?<date>\[[^][]*]) ([A-Z]+) (.*(?:\n(?!\[\d{4}-\d\d-\d\d).*)*)
    

    See the regex demo.

    Details