冷知识 javascript 对特殊符号的转义顺序
//反斜杠转移写在最前面,这样就不会影响后面的转换
searchSegment = searchSegment.replace(/\\/g, "\\\\");
searchSegment = searchSegment.replace(/\+/g, "\\+").replace(/\-/g, "\\-").replace(/\?/g, "\\?").replace(/\*/g, "\\*").replace(/\./g, "\\.");
searchSegment = searchSegment.replace(/{/g, "\\{").replace(/}/g, "\\}").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/\[/g, "\\[").replace(/\]/g, "\\]");
searchSegment = searchSegment.replace(/\$/g, "\\$").replace(/\^/g, "\\^").replace(/\//g, "\/").replace(/\|/g, "\\|");