The following example shows how to find a keyword in a document:
// Create an instance of Parser classusing(Parserparser=newParser(filePath)){// Search a keyword:IEnumerable<SearchResult>sr=parser.Search("page number");// Check if search is supportedif(sr==null){Console.WriteLine("Search isn't supported");return;}// Iterate over search resultsforeach(SearchResultsinsr){// Print an index and found text:Console.WriteLine(string.Format("At {0}: {1}",s.Position,s.Text));}}
The following example shows how to search with a regular expression in a document:
// Create an instance of Parser classusing(Parserparser=newParser(filePath)){// Search with a regular expression with case matchingIEnumerable<SearchResult>sr=parser.Search("page number: [0-9]+",newSearchOptions(true,false,true));// Check if search is supportedif(sr==null){Console.WriteLine("Search isn't supported");return;}// Iterate over search resultsforeach(SearchResultsinsr){// Print an index and found text:Console.WriteLine(string.Format("At {0}: {1}",s.Position,s.Text));}}
The following example shows how to search a text on pages:
// Create an instance of Parser classusing(Parserparser=newParser(filePath)){// Search a keyword with page numbersIEnumerable<SearchResult>sr=parser.Search("line",newSearchOptions(false,false,false,true));// Check if search is supportedif(sr==null){Console.WriteLine("Search isn't supported");return;}// Iterate over search resultsforeach(SearchResultsinsr){// Print an index, page number and found text:Console.WriteLine(string.Format("At {0} (page {1}): {2}",s.Position,s.PageIndex,s.Text));}}