Regex match one of two words
Solution 1:
This will do:
/^(apple|banana)$/
to exclude from captured strings (e.g. $1
,$2
):
(?:apple|banana)
Or, if you use a standalone pattern:
apple|banana
Solution 2:
There are different regex engines but I think most of them will work with this:
apple|banana