I have 2 questions.
1.
regex r1("<.*>.*<.*>");
regex r2("<(.*)>(.*)</(\\1)>");
smatch s1,s2;
string str = "Hello,world<book>C++</book>";
regex_search( str,s1,r1);
regex_search( str,s2,r2);Both the seraches return the result as true but s1.size is not equal to s2.size. What does this mean?
What significance the paranthesis apart from "capture group"?
2.
string data = "<Person>\n""<First>Nico</First>\n""<Last>Jos</Last>\n""</Person>";
regex r("<(.*)>(.*)</(\\1)>");
sregex_iterator pos( data.cbegin( ), data.cend( ),r )
sregex_iterator end;
for( ; pos != end ; ++pos )
{
:
:
}
The above code works fine. But passing the regex as temporary object gives assert failure while iterating the iterator. What is the reason for the assert?regex r("<(.*)>(.*)</(\\1)>");
sregex_iterator pos( data.cbegin( ), data.cend( ),regex ("<(.*)>(.*)</(\\1)>") )