Debian Codegraph @

yo/stl/examples/format.cc

raw
1 #include <string>
2 #include <iostream>
3 #include <regex>
4 #include <iterator>
5
6 using namespace std;
7
8 int main()
9 {
10 //start
11 regex re("([[:alpha:]]+)\\s+(\\d+)"); // letters blanks digits
12
13 smatch results;
14 string target("this value 1024 is interesting");
15
16 if (not regex_search(target, results, re))
17 return 1;
18 //=
19 results.format(ostream_iterator<char>(cout, ""), "$2"s);
20 cout << '\n';
21
22 string reverse(results.format("$2 and $1"));
23 cout << reverse << '\n';
24 }