如何在文本字符串中查找数组项目?我不知道该数组,我不知道文本。但是当一个数组项包含在文本中然后派对!jQuery:在文本字符串中查找数组项目
var arrayString = 'apple | ape | soap',
text = "This a nice apple tree.";
var array = arrayString.split(" | ");
var matchedArrayItem = "..."; // please help on this
if(matchedArrayItem) {
$("body").append('The text contains the array item "'+ matchedArrayItem +'".');
}
正则表达式应该匹配类似/ \ B(苹果| APE |树)\ B/- 你不需要这里的jQuery在所有 – mplungjan
http://stackoverflow.com/questions/1789945/how-我可以检查,如果一个字符串,包含另一个字符串在JavaScript中 – pathfinder