I want to check if a variable is in any of a set of words. For example
'Guava'.match(/\b(apple|mango|orange)\b/ig);
The above does not match, which is correct.
'AppleA'.match(/\b(apple|mango|orange)\b/ig)
This too does not match. Again correct.
'Apple.A'.match(/\b(apple|mango|orange)\b/ig)
This however returns a match, which is not what I want. How do I fix this?
I want a match only if the value is Apple OR apple OR mango OR mAngo, etc.
>Solution :
Try this
'Apple.A'.match(/^(apple|mango|orange)$/ig)
