Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::regex - I do not understand why this testfails.
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-06-23 04:24:04


> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net