In JavaScript, we append /g
to an unquoted string to denote a regular expression.
What if I have a string in a variable and want to use it as a regular expression?
Is this possible? If so, can anyone show me some example code?
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…