Example Program
Wildcard Searching
String matching using wildcards.
A tutorial about the use of wildcard find algorithms.
1#include <iostream>
2#include <seqan/find.h>
3
4using namespace seqan;
5
This program uses the algorithm WildShiftAnd to perform a wildcard search.
6int 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.
SeqAn - Sequence Analysis Library - www.seqan.de
 

Page built @2011/02/08 21:37:01