2 回答
TA贡献1872条经验 获得超3个赞
这是你要找的吗?
//let speech = "blaaaah have you ever look at someone"; // matched
let speech = "have you ever look at someone blaaaah"; // No match
let reference = "have you ever look at someone";
if(new RegExp("\\b"+reference+"\\b$").test(speech)){
console.log("Finally Matched!")
} else {
console.log("No Match At Last!")
}
TA贡献1995条经验 获得超2个赞
您可以使用endsWith如下验证,
var str = "Hello world, welcome to the universe.";
var n = str.endsWith("universe.");
在你的情况下
//let speech = "blaaaah have you ever look at someone"; // matched
let speech = "have you ever look at someone blaaaah"; // No match
let reference = "have you ever look at someone";
if(speech.endsWith(reference)){
console.log("Finally Matched!")
} else {
console.log("No Match At Last!")
}
添加回答
举报