Regex Help Sheet

What is Regex?

Regex (short for regular expressions) is a powerful tool used to define patterns for matching and manipulating text. Two of the modes in the wordle assistant tool use regexes to filter the words in the dictionary.

Basic Regex Elements:

Literal Characters

On their own, literal characters match exactly what you type.

Note that the order of characters within the regex matters, but that the pattern can be matched anywhere in the word. (eg: table vs stabs)

Wildcards and Repetition

Anchors

Character Classes and Ranges

Alternatives

| allows you to specify different alternatives.

^(a|e|i|o|u) is equivalent to ^[aeiou]. Note that the parentheses are required to indicate that the start-of-line anchor is not part of the first alternative.

This is also what lends | its power: it's possible to specify more complicated patterns than with [] since the latter option is limited to only one character.
Taking the final example from above, if we try to construct the equivalent regex with [] instead, we get the following:

Filtering Modes

Practical Examples