insert variable into regex javascript code example
Example: add variable inside regex in javascript
var pattern="cd"
var repeats=3
new RegExp(`${pattern}{${repeats}}`, "g")
var pattern="cd"
var repeats=3
new RegExp(`${pattern}{${repeats}}`, "g")