JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" value="" />
JavaScript
$('input').keyup(function(){
var val = $(this).val().trim().toLowerCase();
// from: http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
//val.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
//from: http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
val = val.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
var re = new RegExp(val, 'ig');
console.log(re);
});