#include <iostream>
#include <regex>
#include <string>
int main() {
std::string text = "This is a {string} with {words} in curly {brackets}";
std::regex pattern("\\{([^}]+)\\}");
std::smatch matches;
std::string::const_iterator searchStart(text.cbegin());
while (std::regex_search(searchStart, text.cend(), matches, pattern)) {
std::cout << "Found: " << matches[1] << std::endl;
searchStart = matches.suffix().first;
}
return 0;
}
/*
run:
Found: string
Found: words
Found: brackets
*/