Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::xpressive use of before(...)
From: Gavin Lambert (boost_at_[hidden])
Date: 2019-04-18 01:42:42


On 17/04/2019 21:39, Simon Giddings wrote:
> std::string strInput = "&9-A02FEfoo";
> sregex re;
>
> re = bos >> as_xpr("&9-A02FE") >> before("foo");
> if(regex_match(strInput, sm, re))
> {
>     strResult = "matched : " + sm[0].str();
> }

regex_match requires matching the entire string. "before" is a
lookahead assertion, which means it doesn't actually consume the "foo"
in the input, so the match fails.

Use regex_search instead if you want to find partial matches.


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