I want to implement incremental search on a list of strings. Consider I have an array containing which contains the strings store,state,stamp,crawl,crow. My application has a te
Below is a function that will incrementally search a string for a substring to match.
public IEnumerable FindAllMatches(string toMatch, string source) {
var last = 0;
do {
var cur = source.IndexOf(toMatch,last);
if ( cur < 0 ) {
break;
}
yield return cur;
last = cur + toMatch.Length;
while(true);
}