1 | // Compiled using g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11) on CentOS 7-1611
|
---|
2 | // using 3.10.0-514.21.2.el7.x86_64 and 3.10.0-514.21.2.el7.centos.plus.i686.
|
---|
3 |
|
---|
4 | #include <cstddef>
|
---|
5 | #include <string>
|
---|
6 | #include <iostream>
|
---|
7 | #include <limits>
|
---|
8 |
|
---|
9 | using namespace std;
|
---|
10 |
|
---|
11 | // this includes perl_matcher_common.hpp, the file containing the templated method with the overflow.
|
---|
12 | #include <boost/regex.hpp>
|
---|
13 |
|
---|
14 |
|
---|
15 | // Example 8.2. Searching strings with boost::regex_search() from https://theboostcpplibraries.com/boost.regex.
|
---|
16 | int main()
|
---|
17 | {
|
---|
18 | std::string s = "Boost Libraries";
|
---|
19 | boost::regex expr(std::string(46341, '.')); // force overflow; use 3,037,000,500 on 64-bit architectures
|
---|
20 | //boost::regex expr("(\\w+)\\s(\\w+)");
|
---|
21 | boost::smatch what;
|
---|
22 | if (boost::regex_search(s, what, expr))
|
---|
23 | {
|
---|
24 | std::cout << what[0] << '\n';
|
---|
25 | std::cout << what[1] << "_" << what[2] << '\n';
|
---|
26 | }
|
---|
27 | }
|
---|