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\"
Regex probably doesn't count as "straight-forward", but this is what I've got:
Regex.IsMatch(listString, "(?<=,|^)" + testWord + "(?=,|$)")
Update: Per Eric's comment below, this should be:
Regex.IsMatch(listString, "(?<=,|^)" + Regex.Escape(testWord) + "(?=,|$)")