You can use javascript's indexOf function.
var str1 = "ABCDEFGHIJKLMNOP";
var str2 = "DEFG";
if(str1.indexOf(str2) != -1){
console.log(str2 + " found");
}
var str1 = "ABCDEFGHIJKLMNOP";
var str2 = "DEFG";
sttr1.search(str2);
it will return the position of the match, or -1 if it isn't found.
Please try:
str1.contains(str2)
I use,
var text = "some/String";
text.includes("/") <-- returns bool; true if "/" exists in string, false otherwise.
If you are worrying about Case sensitive change the case and compare the string.
if (stringvalue.toLocaleLowerCase().indexOf("mytexttocompare")!=-1)
{
alert("found");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With