Mick Ellis

Mick Ellis

  • NA
  • 13
  • 495

Unpredictable Regex expression

Aug 26 2022 2:03 PM

I have a scrabble dictionary containing 200k words in capital letters.
I want to do a wild card search. For example: pattern = "G.NT".
            Regex regex = new Regex(".*" + pattern + ".*");
I get 3 matches using:
            List<ScrabbleWord> s = ScrabbleWords.Where(p => regex.IsMatch(p.Word)).ToList();
I get 2 matches using:
            List<ScrabbleWord> s = ScrabbleWords.FindAll(p => regex.IsMatch(p.Word));
There should be 300+ from AGENT to GENTRY to UNGENTLY
Any advice please. Thanks