I will start straight, here\'s what I have:
var SResults = [];
function ActivateSearch(s) {
SResults = [];
for (var key in Products){
if ((\
Another option would have been to split
and use alternation with positive lookaheads and word boundaries, such as:
^((?=.*\btrampoline\b)|(?=.*\bcover\b)).*$
const regex = /^((?=.*\btrampoline\b)|(?=.*\bcover\b)).*$/gmi;
const str = `Trampoline rain cover 6ft lenght plus extras
Rain cover 6ft lenght plus extras
Trampoline rain 6ft lenght plus extras
Cover trampoline rain 6ft lenght plus extras
Covers trampolines rains 6ft lenght plus extras
`;
let m;
while ((m = regex.exec(str)) !== null) {
m.forEach((match, groupIndex) => {
if (groupIndex == 0)
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
If you wish to explore/simplify/modify the expression, it's been explained on the top right panel of regex101.com. If you'd like, you can also watch in this link, how it would match against some sample inputs.