convert string to regex javascript code example
Example 1: convert string to datetime javascript
var s = '01-01-1970 00:03:44';
var d = new Date(s);
console.log(d); // ---> Thu Jan 01 1970 00:03:44 GMT-0500 (Eastern Standard Time)
Example 2: js string to regex
const regex = new RegExp('https:\\/\\/\\w*\\.\\w*.*', 'g');
Example 3: javascript regex wrap string
"Foo bar cat".replace(/(cat)/ig, "<em>$1</em>");