KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a following problem with my regular expression, I would like it to match caterpillar in the string "This is a caterpillar s 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); }
Tags (comma-separated)
Save Edits
Cancel