String[] index number from regex search
I have a string[] that I search using regex and it returns a list of elements in my string[] that match what I searched for using regex. I would like to find the index number of the elements that are returned.
example:
string[] StringArray = {"aaa","bbb","ccc","ddd","eee"};
string find = "bbb";
List<string> FoundList = new List<string>();
foreach (string Block in StringArray)
{
if (System.Text.RegularExpressions.Regex.IsMatch(Block, find,
System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
FoundList.Add(Block);
}
else
{
//do nothing
}
}
string[] FoundArray = FoundList.ToArray();
it will create FoundArray = {"bbb"} and I wish to find int i such that
StringArray[i] = FoundArray[0]
is true and for senarios where FoundArray has multiple entries I plan to loop it. Any help would be much appreciated.