JSFiddle - React, Tailwind, and code Playground

HTML

<input id="myInput" />
<div id="myDiv"></div>

JavaScript

var myList = "<one></one> $two three#";

$('#myInput').on('input',function(){
    var myRegex = /\bd[^\b]*?\b/gi;
    $('#myDiv').html(myList.match(myRegex));
    
    //var re = new RegExp("\\b"+this.value+"[^]*", "gi");
    //var matches = re.exec(myList);
    //$('#myDiv').html(matches);
});



/*var s = "#div this is a test #john #doe";
var re = /(?:^|\W)#(\w+)(?!\w)/g, match, matches = [];
while (match = re.exec(s)) {
  matches.push(match[1]);
}
alert(matches);/*


/*var pattern = /^[a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/
var qry = 'abc&*';
if(qry.match(pattern)) {
    alert('valid');
}
else{
    alert('invalid');
}*/