
There is no output with the following example, when "Note that I'm 21 years old, not" for m[1], and "35" for m[2], is expected. (according to the example): boost::regex reg("(.*)(\\d{2})"); boost::cmatch cm; const char* text = "Note that I'm 21 years old, not 35."; if (boost::regex_search(text, cm, reg)) { if (cm[1].matched) { std::cout << "(.*) matched: " << m[1].str() << std::endl; } if (cm[2].matched) { std::cout << "Found the age: " << m[2].str() << std::endl; } } Output: (.*) matched: Found the age: Expecting: (.*) matched: Note that I'm 21 years old, not Found the age: 35 Any help would be much appreciated. I am new to regular expression and boost::regex. Thanks, Graham

Graham Reitz wrote:
There is no output with the following example, when "Note that I'm 21 years old, not" for m[1], and "35" for m[2], is expected. (according to the example):
boost::regex reg("(.*)(\\d{2})"); boost::cmatch cm; const char* text = "Note that I'm 21 years old, not 35.";
if (boost::regex_search(text, cm, reg)) { if (cm[1].matched) { std::cout << "(.*) matched: " << m[1].str() << std::endl; }
if (cm[2].matched) { std::cout << "Found the age: " << m[2].str() << std::endl; } ------------------------------------------^
What is m? -- Eric Niebler Boost Consulting www.boost-consulting.com

Oh yikes! Thanks Eric.
I had been staring at that so long! I had grouped several examples together
in one big main() and didn't even notice that.
Graham
On 4/15/07, Eric Niebler
Graham Reitz wrote:
There is no output with the following example, when "Note that I'm 21 years old, not" for m[1], and "35" for m[2], is expected. (according to the example):
boost::regex reg("(.*)(\\d{2})"); boost::cmatch cm; const char* text = "Note that I'm 21 years old, not 35.";
if (boost::regex_search(text, cm, reg)) { if (cm[1].matched) { std::cout << "(.*) matched: " << m[1].str() << std::endl; }
if (cm[2].matched) { std::cout << "Found the age: " << m[2].str() << std::endl; } ------------------------------------------^
What is m?
-- Eric Niebler Boost Consulting www.boost-consulting.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Eric Niebler
-
Graham Reitz