Check if text is in a string
if(str.indexOf(str2) >= 0) {
...
}
Or if you want to go the regex route:
if(new RegExp(str2).test(str)) {
...
}
However you may face issues with escaping (metacharacters) in the latter, so the first route is easier.
ES5
if(str.indexOf(str2) >= 0) {
...
}
ES6
if (str.includes(str2)) {
}