I am searching a list of string in a specific long string.
Imagine the long stream is :Jim participates in a free wrestling competition
and the array is :["Jim","free","not","me","you","wrestling"]
the problem is that i want just the names to be retrieved not the other part.
in the up example i need just "Jim" and not "free" or "wrestling".
by the way, the name can be in any position of array.
this is my code.
title = document.getElementById("title").value
cat_list = document.getElementById("category-all").textContent.replace(/\n\n/g, "\n").replace(/^\s*/g, "").trim().split("\n");
for(i = 0; i < cat_list.length; i++){
if(title.indexOf(cat_list[i]) > -1){
return cat_list[i]
}
}
how can i insert this condition to my code?