JSFiddle - React, Tailwind, and code Playground

JavaScript

var input = '*dog',
    regexp = new RegExp(input, 'ig'),
    str = 'a *dog and a cat';

if(str.search(regexp) >= 0){
    console.log('found!');
}
else{
    console.log('not found!');
}