Skip to content

Instantly share code, notes, and snippets.

@166MMX
Last active December 11, 2015 04:39
Show Gist options
  • Save 166MMX/4547129 to your computer and use it in GitHub Desktop.
Save 166MMX/4547129 to your computer and use it in GitHub Desktop.
Fancy RegEx to match string concatenation for a log message. Something like logger.warn("badaboom " + ex1.message, ex2);
\w+?(?:\.(?:trace|debug|info|warn|error)|\[(?:'(?:trace|debug|info|warn|error)'|"(?:trace|debug|info|warn|error)")\])\((?:"(?:[^\\"]|\\\\|\\")*?"|'(?:[^\\']|\\\\|\\')*?'|[^'"\(\)])+\+(?:"(?:[^\\"]|\\\\|\\")*?"|'(?:[^\\']|\\\\|\\')*?'|[^'"\(\)])+\)
\w+?
(?:
\.
(?:trace|debug|info|warn|error)|
\[
(?:
'(?:trace|debug|info|warn|error)'|
"(?:trace|debug|info|warn|error)"
)
\]
)
\(
(?:
"(?:[^\\"]|\\\\|\\")*?"|
'(?:[^\\']|\\\\|\\')*?'|
[^'"\(\)]
)+
\+
(?:
"(?:[^\\"]|\\\\|\\")*?"|
'(?:[^\\']|\\\\|\\')*?'|
[^'"\(\)]
)+
\)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment