create regex from string js code example
Example 1: js string to regex
const regex = new RegExp('https:\\/\\/\\w*\\.\\w*.*', 'g');
Example 2: using regex in javascript
//Adding '/' around regex
var regex = /\s/g;
//or using RegExp
var regex = new RegExp("\s", "g");
Example 3: js regrex
var s = "Please yes\nmake my day!";
s.match(/yes.*day/);
// Returns null
s.match(/yes[^]*day/);
// Returns 'yes\nmake my day'