#include #include #include using namespace std; #include using namespace boost; void do_stuff(const string & in, const string & re, bool unicode) { if(unicode) { std::cout << "DOING UNICODE:" << std::endl; UnicodeString str(in.c_str()); u32regex reg = make_u32regex(re); u32regex_iterator i(make_u32regex_iterator(str, reg, match_partial | match_perl)), j; while(i != j) { std::cout << "got a " << ((*i)[0].matched ? "" : "partial ") << "match legth: " << (*i)[0].length() << " match position: " << i->position() << " matched: " << string( (*i)[0].first, (*i)[0].second ) << std::endl; ++i; } } else { std::cout << "DOING ASCII:" << std::endl; string str = in; regex reg(re); regex_iterator i(make_regex_iterator(str, reg, match_partial | match_perl)), j; while(i != j) { std::cout << "got a " << ((*i)[0].matched ? "" : "partial ") << "match legth: " << (*i)[0].length() << " match position: " << i->position() << " matched: " << string( (*i)[0].first, (*i)[0].second ) << std::endl; ++i; } } } int main(int argc, char * argv[]) { do_stuff("in summary in math we are using sum", "summary", true); do_stuff("in summary in math we are using sum", "summary", false); return 0; }