How to search for one of two similar strings in Vim?

In Vim, if I want do a search that matches "planA" or "planB", I know that I can do this:

/plan[AB]

This works because the regex allows for either A or B as its set of characters.

But how can I specify one of two complete strings? For example, "planetAwesome" or "planetTerrible"?

This will match both of these, along with "planetAnythingHereAsLongAsItsJustLetters":

planet\([a-zA-Z]*\)

How can I match only strings that match "planetAwesome" or "planetTerrible" exactly?


Solution 1:

/planet\(Awesome\|Terrible\)

To see the relevant documentation, issue :help /, and scroll down to the section “The definition of a pattern”.

Solution 2:

To add to Gilles' answer, you might want to add a few things in there:

/\<planet\(Awesome\|Terrible\)\>

\< marks the beginning of a 'word' (essentially alphanumerics)
\> marks the end of a 'word' (essentially alphanumerics)