I have the following problem with my regex, I would like it to match the caterpillar in the line "This is a caterpillar tooth", but it matches cat. How can I change it?
List<string> women = new List<string>() { "cat","caterpillar","tooth" }; Regex rgx = new Regex(string.Join("|",women.ToArray())); MatchCollection mCol = rgx.Matches("This is a caterpillar s tooth"); foreach (Match m in mCol) { //Displays 'cat' and 'tooth' - instead of 'caterpillar' and 'tooth' Console.WriteLine(m); }
c # regex
Grant smith
source share