C++ examples for boost:regex
Using Regular Expressions to Split a String with Boost's regular expressions
#include <iostream> #include <string> #include <boost/regex.hpp> int main() { std::string s = "who,lives:in-a,test test: test::test -PIOU test?"; boost::regex re(",|:|-|\\s+"); boost::sregex_token_iterator p(s.begin(), s.end(), re, -1); boost::sregex_token_iterator end; while (p != end) std::cout << *p++ << '\n'; }