更新时间:2021-12-17 22:11:25
您需要传递第二个参数:
var r = new RegExp(keyword, "i");
您还需要转义字符串中的任何特殊字符,以防止进行正则表达式注入攻击.
You will also need to escape any special characters in the string to prevent regex injection attacks.
将正则表达式修饰符选项传递给RegExp对象