dictNum2 = {{"eins", 1}, {"zwei", 2}, {"drei", 3} ...};
foreach (KeyValuePair<string, int> dsa in dictNum2)
{
Regex regexTemp = new Regex(dsa.Key);
MatchCollection matchTemp = regexTemp.Matches(stringInput);
if ((stringInput.Contains(dsa.Key) && dsa.Value < 10))
{
var indexList = Regex.Matches(stringInput, dsa.Key).Cast<Match>().Select(m => m.Index).ToList();
indexList.AddRange(indexList);
for(int i = 1; i < indexList.Count; i++)
{
if(indexList[i] == indexList[i-1] + dsa.Key.Length)
{
inaRow++;
}
}
}
}
The idea is: need to find the number of words following each other in a string, that contains in a dictionary. I have piece of code that works for something like "zweizweizwei", but on input could be string like that:
"zweihundertzweidreiundzwanzig" or "zweiunddreieins"
Is there way to solve that? Thanks