This one is a little complicated and somewhat out of my league. I want to sort through a list of words and eliminate those that don't contain a specific set of characters, however those characters can be in any order and some may occur more than others.
I want the regex to look for any words with:
e
0 or 1 times
a
0 or 1 times
t
0 or 1 or 2 times
For example the following would work:
eat
tea
tate
tt
a
e
The following would not work
eats
teas
tates
ttt
aa
ee
Lookaround Regex is new to me, so I'm not 100% sure on the syntax (any answer using a lookaround with an explanation would be awesome). My best guess so far:
Regex regex = new Regex(@"(?=.*e)(?=.*a)(?=.*t)");
lines = lines.Where(x => regex.IsMatch(x)).ToArray(); //'text' is array containing words