I\'m reading a comma-delimited list of strings from a config file. I need to check whether another string is in that list. For example:
\"apple,banana,cheese\"
This works, but regexes are pretty slow if they get complicated. That said, the word boundary anchor makes this sort of thing pretty easy.
var foods = "apple,banana,cheese"; var match = Regex.Match(foods, @"\bapple\b"); if (match.Success) Console.WriteLine(match.Value);