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

Posted by Nathan Long on Super User See other posts from Super User or by Nathan Long
Published on 2011-02-23T22:34:28Z Indexed on 2011/02/23 23:27 UTC
Read the original article Hit count: 261

Filed under:
|

This is a pretty simple regex question, I think. 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, to match both planetAwesome and planetTerrible, this doesn't work:

planet[Awesome|Terrible]

... because it's looking for planetA or planetw or planete, etc. Nor does this:

planet['Awesome'|'Terrible']

This will match both of these, along with planetAnythingHereAsLongAsItsJustLetters:

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

But how can I match only strings that match planetAwesome or planetTerrible exactly?

© Super User or respective owner

Related posts about vim

Related posts about regex