#include using namespace std; int main() { regex re("\\s+"); string s(" two words"); for (auto it = sregex_token_iterator(s.begin(), s.end(), re, -1); it != sregex_token_iterator(); ++it); return 0; }