I'm trying to search a string for any word of another string with javaScript. Let's say I have the following string that I want to search in:
"Oxford Street 100 London"
And my search term is like this:
"oxford london"
The above searchterm should give me a match since oxford and london is a part of the string to search in.
I have tried str.indexOf("oxford london") !== -1 but that doesn't work since it's not a combined word in the string to search in.
Is there any way of doing this?
new RegExp("oxford london".split(/\W+/).join("|"), 'i')?