In my JavaScript code, I have a variable assigned as var num = "x"
. How can I incorporate this variable into a regular pattern?
var pattern = /"i want to include the variable num here"/i
If I were working with a string, it would look something like this:
var str = ""+num+"";