I have an input that can have only 2 values apple or banana. What regular expression can I use to ensure that either of the two words was submitted?
apple
banana
This will do:
/^(apple|banana)$/
to exclude from captured strings (e.g. $1,$2):
$1
$2
(?:apple|banana)
Or, if you use a standalone pattern:
apple|banana
1.4m articles
1.4m replys
5 comments
57.0k users