我想检查一个变量是否在一组单词中的任何一个中。例如
'Guava'.match(/\b(apple|mango|orange)\b/ig);
以上不相符,这是正确的。
'AppleA'.match(/\b(apple|mango|orange)\b/ig)
这也不匹配。再次正确。
'Apple.A'.match(/\b(apple|mango|orange)\b/ig)
然而,这会返回一个匹配项,这不是我想要的。我该如何解决这个问题?
仅当值为
Apple
OR apple
OR mango
OR mAngo
等时,我才想要匹配。