Invalid regular expression: unmatched parentheses

Unmatched ) in Javascript regular expression您的某些字符串包含错误')'。你需要逃避这个。这是这样做的功能:

function escapeRegExp(str) {
  return str.replace(/[-[]/{}()*+?.\^$|]/g, "\$&");
}
原文地址:https://www.cnblogs.com/mafeng/p/7090079.html