Forum Discussion
Emilian Ertel
May 28, 2018Copper Contributor
regex matching for multi-line strings
According to the documentation (https://docs.loganalytics.io/docs/Language-Reference/References/Regular-Expressions-syntax😞
"Flag syntax is xyz (set) or -xyz (clear) or xy-z (set xy, clear z)."
Unfortunately I did not find an example in the documentation on how to set the flags.
Example:
datatable(Message:string)
[
"Hello world",
"Hello
multi-line
world",
"foo bar"
]
| where Message matches regex "^Hello.*line.*$"
returns no result because the m and s flags are not set.
The question is: how to set the "multi-line" (m) and the "dot matches newline" (s) flags in the query ?
Thank you in advance,
bye //emil.
The solution is:
| where Message matches regex "(?ms)^Hello.*\\s*.*line.*$"
Thanks Yoni !
1 Reply
Sort By
- Emilian ErtelCopper Contributor
The solution is:
| where Message matches regex "(?ms)^Hello.*\\s*.*line.*$"
Thanks Yoni !