C++: posix regex error reporting?
- by Helltone
I'm writing a small C++ program that parses some strings. I chose to use C's regex.h because I only need POSIX Extended Syntax and I'm concerned with portability.
However, I've just noticed that when regexec fails to match, it returns != 0 and I have no idea of what was wrong :-(. I expected to be able to display at least a small message like:
line:col: Syntax error
or
giig sdoigosdigo* sodfg
^
Syntax error
Is there a way to know which character did not match?
Should I use boost:regex instead?
For reference, my regex is:
"^"
"[ ;\t\n]*"
"(" // (1) identifier
"[a-zA-Z_][a-zA-Z0-9_]*"
")"
"[ \t]*"
"(" // (2) non-marking
"\["
"(" // (3) non-marking
"[ \t]*"
"(" // (4..n-1) argument
"[a-zA-Z0-9_]+"
")"
"[ \t]*"
","
")*"
"[ \t]*"
"(" // (n) last argument
"[a-zA-Z0-9_]+"
")"
"]"
")?"
"[ \t\n]*"
";"
Which matches for instance blablabla[arg1, arg2];