我有一个字符串和一个字典中的两个单词,我想知道在我的字符串中是否有不是我的字典单词。
var string = 'foobarfooba';
var patt = new RegExp("[^(foo|bar)]");// words from dictionary
var res = patt.test(string);
console.log(res);//return false
它应该返回true,因为在我的字符串中也有'ba',但是它返回false。
如果在一串文本中至少找到一次特定的匹配文本,我需要设置一个条件为真,例如:
str = "This is some text containing the word tiger."
if string.match(str, "tiger") then
print ("The word tiger was found.")
else
print ("The word tiger was not found.")
如何检查文本是否在字符串中的某个位置找到?