need help checking if a text contains a string to search for.
Say that I have a text
"somerandomtextstringexampleexample_1"
And I want to compare with for example this String
"example_1_e23wet_est1"
Now because the text contains "example_1" I want the function to return "example_1" and not also "example". (But if the string would have been "example_4_e23wet_est1" it should have returned just "example)
So the function takes 2 arguments
function searchForString(text,stringToCompare){
var foundstring;
...
if(foundstring)
return foundstring//In this case "example_1"
}
But then I'm pretty lost on how to carry on here since "indexOf" don't work here.
Thanks in advance =)
example_1somerando? You should precisely define the rules for your function and then have another go.