How to use a variable in regex pattern in JavaScript? [FIXED]

How to use a variable in regex pattern in JavaScript? [FIXED]

More to explore

Based on this image's title: “How to use a variable in regex pattern in JavaScript? [FIXED]