How do you print the string representation of a std::regex
?
Say I have a collection of patterns, and I'd like to print the first one that matches:
std::vector<std::regex>> patterns = Get();
for (auto pattern: patterns){
if (std::regex_match("file.txt",pattern)){
std::cout << "matched on pattern: " << /* ? pattern ? */ << '\n';
}
}
std::cout
will not work on std::regex
.
There doesn't seem to be any methods to get the string representation.
Are we expected to carry around a string separately, or am I missing something in the docs?