I want to split std::string by regex.
std::string
regex
I have found some solutions on Stackoverflow, but most of them are splitting string by single space o
string s = "foo bar baz"; regex e("\\s+"); regex_token_iterator i(s.begin(), s.end(), e, -1); regex_token_iterator end; while (i != end) cout << " [" << *i++ << "]";
prints [foo] [bar] [baz]
[foo] [bar] [baz]