
AMDG Mauricio Gomes wrote:
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).
I know this probably is just a regex (lack of ) knowledge problem on my part and not a boost::regex problem but I could not find a better forum than this one to ask for help.
static const std::string& REGEX1 = "\\s*(\\w+)\\s+([\\d,\\.]+)\\s+([\\d,\\.]+)\\s([\\d,\\.]+)\\s*$"; static const std::string& REGEX2 = "\\s*(\\w+){1}\\s*(\\w+){1}\\s*(\\w+){1}\\s+([\\d,\\.]+){1}\\s+([\\d,\\.]+){1}\\s([\\d,\\.]+){1}\\s*$";
It would probably work better if you used \\s+ consistently for internal spaces. In Christ, Steven Watanabe