var str = "This is a test sentence";
var hasTest = str.includes("test");
var stringHasAll = (s, query) =>
// convert the query to array of "words" & checks EVERY item is contained in the string
query.split(' ').every(q => new RegExp('' + q + '', 'i').test(s));
// tests
[
'', // true
' ', // true
'aa', // true
'aa ', // true
' aa', // true
'd b', // false
'aaa', // false
'a b', // false
'a a a a a ', // false
].forEach(q => console.log(
stringHasAll('aA bB cC dD', q)
))
Run code snippet
const string = "This is a very long string";
const match = string.match(/very/);
console.log(match) // ['very', index: 10, input: 'This is a very long string', groups: undefined]