I have a search string that I want to test against titles stored in another array. for example
title = ["Handbook on Quality Assurance", "Water Quality Handbook", ...]
searchStr = "Handbook Quality"
I want to use regular expressions to test it each word is found at least once in the title but it doesn't matter in what order.
I don't know how many words will be in the search string.
new RegExp = ("("+searchStr.replace(" ", ")+.*(") + ")+");
(which would give /(Handbook)+.*(Quality)+/ in the above example)
but this matches only title and not title (which I want to include).
I was also thinking of using somewthing like /(Handbook|Quality) \1/ But if a title has the word Quality twice and not Handbook, it will still match (which I don't want)....
Because I have to loop through the title array (which is on the order of 200+ elements) I don't want to have to do a sub loop for each of the search terms (which I don't how many there are) but can't think of any other way...