Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <boost/regex.hpp>
- #include <iostream>
- #include <string>
- int main()
- {
- std::string text("dgdr<text>55,99.5,99.6</text>svf<text>55,99.5,99.6</text>frdg");
- const char* pattern = "<text>(.*?)</text>";
- boost::sregex_iterator it(text.begin(), text.end(), boost::regex(pattern));
- boost::sregex_iterator end;
- for (; it != end; ++it) {
- std::string novotexto(it->str());
- //get inverse regex
- boost::sregex_token_iterator p(novotexto.begin(), novotexto.end(), boost::regex("<(.|\n)*?>"), -1);
- boost::sregex_token_iterator den;
- for (;p != den; ++p)
- {
- std::string m(p->first, p->second);
- std::cout << m << std::endl;
- boost::sregex_iterator sp(m.begin(), m.end(), boost::regex("[^,]+"));
- boost::sregex_iterator fim;
- for (; sp != fim; ++sp) {
- std::cout << sp->str() << std::endl;
- }
- }
- }
- std::cin.get();
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement