
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Parsing Issue with Escape Characters
Hello,
I have an override that inspects the message field and pulls out a filename and assigns it to deviceCustomString1.
eg.
submessage[0].pattern[0].regex = The file "([^"]+)" was accessed
...
My override works for most cases but breaks when the file directory string contains escape characters.
eg. msg=The file "C:\\windows\newfile" was accessed
the output in the logger would be
The file "C:\\windows
ewfile" was accessed
Where \n is treated as a new line escape character, and nothing parses properly.
Given that the [^"]+ statement does not include new line, I tried changing my regex to the following:
submessage[0].pattern[0].regex = The file "((?:\\n|[^"])+)" was accessed
This would not work. I also tried
submessage[0].pattern[0].regex = The file "((?:\n|[^"])+)" was accessed
and I also tried
submessage[0].pattern[0].regex = The file "((?:\\\n|[^"])+)" was accessed
None of these regex statements worked. Is there a simplier way to get the logger to ignore esscape characters in the message field? Perhaps a declaration of some kind at the beginning of the override?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
For every "\" that you need to be escaped you need to add one more. So in your case if the regex you need to specify that you may encounter "\" and of course to be escaped (which means \\)
Differently the results may be unexpected.
A quick example in your case (C:\\windows\newfile") maybe will be:
regex=[C-D]:\\\\\\w+\\\\w+