
Hi, I experience big troubles with regex matching. The code below should obviously match 'abc', but does not, because it tries to match the whole string. If r='abcdefg', then match is successfull, but if it is only 'abc' and input is 'abcdef', the match always fails as described below. boost::match_resultsstd::string::const_iterator m; std::string inp = "abcdefg"; boost::regex r = "abc"; if (!boost::regex_match(inp, m, r, boost::match_default)) // always fails, don't know why How can I successfully match 'abc' agains input 'abcdefg'? Thank you very much in advance, Kalin

Kalin Nakov wrote:
Hi,
I experience big troubles with regex matching. The code below should obviously match 'abc', but does not, because it tries to match the whole string. If r='abcdefg', then match is successfull, but if it is only 'abc' and input is 'abcdef', the match always fails as described below.
boost::match_resultsstd::string::const_iterator m; std::string inp = "abcdefg"; boost::regex r = "abc"; if (!boost::regex_match(inp, m, r, boost::match_default)) // always fails, don't know why
How can I successfully match 'abc' agains input 'abcdefg'?
Use regex_search. John.
participants (2)
-
John Maddock
-
Kalin Nakov