23 Jun
2010
23 Jun
'10
8:24 a.m.
Below it is a self contained example and the output it produces.
I thought I would get a match for REGEX2 but not for REGEX1 in string s. However REGEX1 matches and produces weird (for me) results. I would expect REGEX1 only matches for strings with 6 terms (3 words and 3 numbers).
static const std::string& REGEX1 = "\\s*(\\w+)\\s+([\\d,\\.]+)\\s+([\\d,\\.]+)\\s([\\d,\\.]+)\\s*$";
Ugh? REGEX1 will match a string containing *one* word (the "(\\w+)" part), followed by three numbers which may also contain any number of "."'s or ","'s. And that's exactly what it's doing isn't it? Maybe I've missed something? John.