Regex for Wordle

You may use this regex with a positive and negative lookahead conditions:

^pr(?=[a-z]*i)(?![a-z]*[outyase])[a-z]{3}$

Regex Explanation:

  • ^: Start
  • pr: Match pr
  • (?=[a-z]*i): Positive lookahead to make sure we have an i ahead after 0 or more letters
  • (?![a-z]*[outyase])): Negative lookahead to disallow any of the [outyase] characters
  • [a-z]{3}: Match 3 letters

Demo Screenshot:

enter image description here


Trivially, you can use:

^pr([^outyase][^outyase]i|[^outyase]i[^outyase]|i[^outyase][^outyase])$

Also, according to your site, there's actually four words matching, not just two:

  • prick
  • primi
  • primp
  • prink