how to put regex in string in js code example
Example 1: using regex in javascript
//Adding '/' around regex
var regex = /\s/g;
//or using RegExp
var regex = new RegExp("\s", "g");
Example 2: add variable inside regex in javascript
var pattern="cd"
var repeats=3
new RegExp(`${pattern}{${repeats}}`, "g")