I have created a regular expression with a variable, which is dynamically passed.
new RegExp("(" + variable_name + ":\\((.*?)\\))");
It perfectly results in /(ABC:\((.*?)\))/ (if variable_name is ABC)
But, If I pass an option as
new RegExp("(" + variable_name + ":\\((.*?)\\))") + "g",
it gives me the regular expression in string format
"/(ABC:\((.*?)\))/g"
and the match() function fails. Is there any good way to pass option without converting the expression into string.