If your requirement is to find
each set of 50 words
, then I think the
Matches
method of
Regex
class can be used as shown below:
string result = "one two three four five six seven eight nine";
int numberOfWords = 2;
string regexMatch = @"(\w+\s*){" + numberOfWords + @"}";
MatchCollection foundWords= Regex.Matches(result, regexMatch);
foreach (Match match in foundWords)
Console.WriteLine (match.Value);
In the above example I have taken
numberOfWords = 2
to illustrate the point. It can be replaced with 50.