This is a little harder and a bit out of my league. I want to sort the list of words and eliminate those that do not contain a specific set of characters, however these characters can be in any order, and some may occur more than others.
I want the regular expression to look for the words:
e0 or 1 time
a0 or 1 time
t0 or 1 or 2 times
For example, the following will work:
eat tea tate tt a e
The following steps will not work
eats teas tates ttt aa ee
Lookaround Regex is new to me, so I'm not 100% sure of the syntax (any answer using lookaround with an explanation would be awesome). So far, I guess:
Regex regex = new Regex(@"(?=.*e)(?=.*a)(?=.*t)");
lines = lines.Where(x => regex.IsMatch(x)).ToArray();
NealR source
share