Get string between 2 delimiters using C++ STl TR1 regular expressions

  • Thread starter Thread starter sgrm123
  • Start date Start date
S

sgrm123

Guest
I want to extract string between open and close bracket.So if the content is

145(5)(7)

the output must be

5

7

I tried with C++ STL TR1 using below code

const std::tr1::regex pattern("\\((.*?)\\)");

// the source text
std::string text= "145(5)(7)";

const std::tr1::sregex_token_iterator end;
for (std::tr1::sregex_token_iterator i(text.begin(),
text.end(), pattern);
i != end;
++i)
{
std::cout << *i << std::endl;
}

I am getting the output as,

(5)

(7)

I want the output without delimiters.

Please help me to meet my requirement using STL TR1.

Continue reading...
 
Back
Top