|
Boost Users : |
Subject: Re: [Boost-users] boost::regex - I do not understand why this test fails.
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-06-22 22:12:48
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
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