[Solved] Extract Log file value

[ad_1]

I think you can do it using a positive lookahead until you encounter INFO or DEBUG or WARN.

ERROR[\S\s]*?(?=\s+INFO|DEBUG|WARN)

  • Match ERROR
  • Match any whitespace character or any non-whitespace character zero or more times non greedy [\S\s]*
  • A positive lookahead (?=
  • Assert that what follows is one or more whitespaces \s+
  • Followed by either INFO or DEBUG or WARN INFO|DEBUG|WARN
  • Close the positive lookahead )

Demo

Regex r = new Regex(@"ERROR[\S\s]*?(?=\s+INFO|DEBUG|WARN)");

1

[ad_2]

solved Extract Log file value