I am iterating through a list of words and I need to find words that contain ALL of desired characters. I know how to find a substring but that find words that have the characters next to each other. I want to create something that determines if the string contains all of the characters even when they are not next to each other.
For example if I have a string "ent", words in the list like "element", "nintendo", "telephone" would show up.
I currently something have this logic:
String textLine = "element";
Regex regX = new Regex("e|n|t");
bool containsAny = regX.IsMatch(textLine);
You can use Linq
var desiredChars = "ent"; var word = "element"; bool contains = desiredChars.All(word.Contains);