How to put a variable into a regex check

Possibly an easy one and I may have missed it in the lessons, cant seem to find the answer online.

if I want to check for /example/ in text, but I want example to be a variable, how do I stop the programme seeing ‘example’ as text and see it as the var?

How to use a Variable in Regular Expression pattern in JavaScript

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.