First and foremost, I do not know RegEx but am trying to piece something together to make this work. Just wanted you to be forewarned. ;)
Anyways, I'm trying to create a regular expression to take a word from an array and see if it matches a word in another array. I only want the search to return true if the keyword array string contains the searchTerm word. (i.e. oneone would be false, so would ones). Any help is GREATLY appreciated.
var searchTerm = ['one','two','three'];
var keywords = ['String which contains one', 'This string is 2', 'Three is here'];
var keywordIndex;
// loop through each keyword array
$.each(keywords, function(i) {
$.each(searchTerm, function(j) {
var rSearchTerm = new RegExp('\b' + searchTerm[j] + '\b',i);
// if search term is found, swap accordion div content
if (keywords[i].search(rSearchTerm) > -1) {
keywordIndex = i; // grouping keyword is in
}
}); // end searchTerm loop
}); // end keyword loop