I can't, as this is a const global variable... ;-)
Works fine with ternary operator, but I don't think it really matters in this case.
On a different note, why don't you use a much simpler regex?
The compiler outputs a filename, and a colon followed by a digit (= line number), and/or a colon followed by a space character.
Everything after the second colon is the message. Everything before that colon is the pathname. So... match for a colon followed by a digit, and a colon followed by a space.
Something like
: ({0-9}+:)?\s, with some additional
()s added to grab the filename, line number, and text.
EDIT: there is an additional space in the above regex that doesn't belong there, but the super-smart forum software would otherwise insert a
We don't know what a pathname looks like, or whether it's French or Chinese, whether it's an Unix filename, DOS, or whatever. And we don't really care. Whatever it is, it ends with a colon followed by a digit followed by a colon and a space, or a colon followed by a space character.
You just have to pay attention not to match a colon inside
D:\, but since neither a digit, nor a space is legal in that place, this should be no issue.