| Example Program Wildcard Searching String matching using wildcards. File "find_wild.cpp" A tutorial about the use of wildcard find algorithms.
1 | #include <iostream>
2 | #include <seqan/find.h>
3 |
4 | using namespace seqan;
5 |
This program uses the algorithm WildShiftAnd to perform a wildcard search.
6 | int main()
7 | {
8 | String<char> hayst = "If you must cross a course cross cow across a crowded cow crossing, "
9 | "cross the cross coarse cow across the crowded cow crossing carefully.";
10 | String<char> ndl = "cr?o[uw]";
The pattern matches e.g. "cow", "crow", and "cou", but not "cros".
11 | Finder<String<char> > finder(hayst);
12 | Pattern<String<char>, WildShiftAnd> pattern(ndl);
13 |
14 | while (find(finder, pattern)) {
15 | ::std::cout << position(finder) << "\n";
16 | }
17 | return 0;
18 | }
19 |
Output 22 35 49 56 93 109 116 Note that the printed positions are the positions of the last characters of the matches. See WildShiftAnd See Also Searching SeqAn - Sequence Analysis Library - www.seqan.de