The 3 Rs of Finder

man in black and white polo shirt beside writing board
Photo by Pixabay on Pexels.com

I recently spoke with a constructor wanting help finding answer words to fit her theme. That prompted this post, which uses a similar idea, answer words with three Rs, to demonstrate Finder features.

Search and OneLook search

Our first attempt is R*R*R. Try the [links] here to see the results:

R*R*R [Search] [OneLook search]

Good start! Every answer has at least 3 Rs. * means any number of any characters.

Note that since Search and OneLook search have similar syntax, you can try clicking both for different results. Search (and RegEx) use our internal database. OneLook uses external data, and never returns more than 1,000 results.

The results above start and end with R. We can remove that restriction like this:

*R*R*R* -- [Search] [OneLook search]

Most constructors can stop here. (Yay!) You already have plenty of useful results. But just be way of demonstration, let’s go on.

Suppose you want words with at least three Rs, but they can’t start or end with an R. Square brackets to the rescue. [ABC] or [A-C] means any single character A, B, or C. Now for the hat trick. [^ABC] means any single character except A, B, or C. We can use [^R] to mean any letter except R. Like this:

[^R]*R*R*R*[^R] -- [Search] [OneLook search]

Lots of great possibilities with at least 3 Rs. But now suppose we want to find words with exactly 3 Rs. For this you need RegEx.

RegEx

RegEx is powerful. The examples here just scratch the surface. Its syntax is similar but frustratingly different. Let’s start with this:

[^R]*R

The ^R in square brackets means a single letter that isn’t R. Same as before. The * here means repeat that thing that comes before it zero or more times. Then follow that up with an R.

To make the query useful, we must start with ^ (which confusingly now means “the beginning of the word”) and end with $ which means “the end of the word”.

^[^R]*R$ -- [RegEx]

That finds words that start with a string of letters that aren’t R, and then ends with an R. Not what we want, but we’re making progress.

To find words with at least 3 Rs, we need to repeat the sequence [^R]*R three times. We do that by putting round brackets around that sequence, and then specifying the number of times to repeat that sequence in curly brackets.

^([^R]*R){3}$ -- [RegEx]

So close! The only problem is that every word ends with an R, which is a restriction we don’t want. Adding [^R]* will add an arbitrary number of non-R letters to the end.

^([^R]*R){3}[^R]*$ -- [RegEx]

Nearly there! None of the answer words start with R, but some end with R because that * can mean zero or more. We could include another [^R] just before the terminal $, or we could use the plus sign to say one or more non-Rs.

In fact, let’s use plus to add one more restriction — no more double Rs (no more two in a row.)

^([^R]+R){3}[^R]+$ -- [Regex]

Nobody needs to learn all this to be a successful constructor, but if this sort of thing is fun for you, this post gives you a good start.

1 comment

Your thoughts?