Try with this one instead :
string str_regex("ATI3\r\nv(\\d+[.]\\d+)\r\nOK\r\n");
Notice that the \
of \d
is escaped to become \\d
.
Applying the same change to your two alternative regular expressions should also make those work.
Explanation :
This is not a problem with the newline or carriage return matching, but rather with escape sequences in string literals. \d
is not a valid escape sequence for a string literal - in fact my compiler warns me about this :
warning: unknown escape sequence: '\d' [enabled by default]
It is a shortcut for [:digit:]
recognized by boost::regex. In order for the boost::regex library to 'see' the \
, it needs to be escaped.