regex pattern extract the opti-id <novel-li opti-id="aaa">
std::string str = "<novel-li opti-id=\"aaa\">"; std::smatch result; std::regex re("opti-id=\"(.*?)\""); while (std::regex_search(str, result, re)) { for (auto x : result) std::cout << x << " "; std::cout << std::endl; str = result.suffix(); }