I want to check if my string contain particular substring.
1.What function should i use to perform this in javascript or jquery or using regex
for example
var a = "i am string";
var b = "i am webpage";
if(var_a_has_string)
{
alert("it is string")
}
if(var_b_has_webpage)
{
alert("it is webpage")
}
sorry for repetition being a beginner i found some similar question but did not get the given answers here
https://stackoverflow.com/questions/5038105/checking-if-a-string-contains-a-certain-substring
Fastest way to check a string contain another substring in Javascript?
2.which function to be used if i want to retrieve the particular substring from my string
like "webpage" string or "string" string
for example
var a = "i am string";
var b = "i am webpage";
if(var_a_has_string)
{
var c = get_string_from_a(a)
}
if(var_b_has_webpage)
{
var d = get_webpage_from_b(b)
}