Wolfram Archive
Wolfram Programming Lab is a legacy product.
All the same functionality and features, including access to Programming Lab Explorations, are available with Wolfram|One.
Start programming now. »
Try it now »
(no sign-in required)

Find Letter Patterns

Find dictionary words that have interesting patterns of letters.

Run the code to find words that start with a and end with z. Try other letters:

SHOW/HIDE DETAILS

DictionaryLookup returns dictionary words that match a pattern.

In a pattern, ___ stands for any sequence of zero or more letters.

This returns dictionary words that start with a, followed by zero or more letters, followed by z:

DictionaryLookup["a" ~~ ___ ~~ "z"]

HIDE DETAILS
DictionaryLookup["a" ~~ ___ ~~ "z"]

Find words that contain kk. Try other letters:

SHOW/HIDE DETAILS

Patterns can contain any combination of letters and blank sequences, including more than one blank sequence.

This returns words that contain kk somewhere in them:

DictionaryLookup[___ ~~ "kk" ~~ ___]

HIDE DETAILS
DictionaryLookup[___ ~~ "kk" ~~ ___]

Find words that contain all the vowels in order. Try other letter patterns (like the letters of your name):

SHOW/HIDE DETAILS

Are there any words that contain all of the vowels in sequence? Use DictionaryLookup to find out:

DictionaryLookup[___ ~~ "a" ~~ ___ ~~ "e" ~~ ___ ~~ "i" ~~ ___ ~~ "o" ~~ ___ ~~ "u" ~~ ___]

Here are the words that contain the letters of Stephen in order, starting with s and ending with n:

DictionaryLookup[ "s" ~~ ___ ~~ "t" ~~ ___ ~~ "e" ~~ ___ ~~ "p" ~~ ___ ~~ "h" ~~ ___ ~~ "e" ~~ ___ ~~ "n"]

HIDE DETAILS
DictionaryLookup[___ ~~ "a" ~~ ___ ~~ "e" ~~ ___ ~~ "i" ~~ ___ ~~ "o" ~~ ___ ~~ "u" ~~ ___]

Find words that start and end with the same three letters. Try other letter patterns:

SHOW/HIDE DETAILS

If a named pattern like x_ occurs more than once in a pattern, every occurrence has to match the same letters. This pattern matches words that start and end with the same three letters:

DictionaryLookup[x_ ~~ y_ ~~ z_ ~~ ___ ~~ x_ ~~ y_ ~~ z_]

Find words that repeat the same sequence of letters twice:

DictionaryLookup[x___ ~~ x___]

HIDE DETAILS
DictionaryLookup[x_ ~~ y_ ~~ z_ ~~ ___ ~~ x_ ~~ y_ ~~ z_]