1 | #include <iostream>
|
---|
2 | #include <boost/algorithm/searching/boyer_moore.hpp>
|
---|
3 |
|
---|
4 | int
|
---|
5 | main( int, char ** )
|
---|
6 | {
|
---|
7 | const char *needle = "find";
|
---|
8 | const char *haystack = "this is a string that we search if we want to find the needle.";
|
---|
9 |
|
---|
10 | const char *hit = boost::algorithm::boyer_moore_search<const char *,const char *> (
|
---|
11 | haystack, haystack + strlen( haystack ),
|
---|
12 | needle, needle + strlen( needle ) );
|
---|
13 |
|
---|
14 | if (hit) {
|
---|
15 | std::cout << "Found it!" << std::endl;
|
---|
16 | } else {
|
---|
17 | std::cout << "No match" << std::endl;
|
---|
18 | }
|
---|
19 |
|
---|
20 | return 0;
|
---|
21 | }
|
---|