//反斜杠转移写在最前面,这样就不会影响后面的转换
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, "//|");
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281064.html