I need to check whether a string contains another string or not?
var str1 = "ABCDEFGHIJKLMNOP";
var str2 = "DEFG";
Which function do I use to find out if str1 contains str2?
I need to check whether a string contains another string or not?
var str1 = "ABCDEFGHIJKLMNOP";
var str2 = "DEFG";
Which function do I use to find out if str1 contains str2?
Check out JavaScript's indexOf function. http://www.w3schools.com/jsref/jsref_IndexOf.asp
Below code you can check "hello" string is exit or not in given string.
I hope this answer is useful for you.
I use,
var text = "some/String"; text.includes("/") <-- returns bool; true if "/" exists in string, false otherwise.
This is working for me
If you are worrying about Case sensitive change the case and compare the string.
Please try: