|
@@ -58,6 +58,7 @@ func init() {
|
|
|
|
|
|
//
|
|
|
SymInterCon = qu.ObjArrToStringArr(SpecialSymbols["symintercon"].([]interface{}))
|
|
|
+ //log.Println(string(DealSinAndDouQuotes([]rune("安顺市西\"秀区园林局\"环卫设备\"项目"))))
|
|
|
}
|
|
|
|
|
|
//去除首尾空格、换行、回车
|
|
@@ -81,6 +82,8 @@ func RemoveHESymCode(val string) string {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //单引号和双引号特殊处理
|
|
|
+ text = DealSinAndDouQuotes(text)
|
|
|
return string(text)
|
|
|
}
|
|
|
|
|
@@ -376,3 +379,33 @@ func DelContext(pairedIndex map[int]int, text []rune) []rune {
|
|
|
}
|
|
|
return result
|
|
|
}
|
|
|
+
|
|
|
+func DealSinAndDouQuotes(text []rune) []rune {
|
|
|
+ stext := string(text)
|
|
|
+ for _, v := range []string{"\"", "'"} {
|
|
|
+ sReg := regexp.MustCompile(v)
|
|
|
+ sIndex := sReg.FindAllStringIndex(stext, -1)
|
|
|
+ length := len(sIndex)
|
|
|
+ if length > 0 {
|
|
|
+ if len(sIndex)%2 == 0 { //符号是成对出现的
|
|
|
+ si := sIndex[0][0]
|
|
|
+ ei := sIndex[length-1][1]
|
|
|
+ //val := stext[si:ei]
|
|
|
+ if si == 0 { //以单双引号开头
|
|
|
+ end := stext[ei:]
|
|
|
+ for _, r := range SymInterCon {
|
|
|
+ if r == string(end) {
|
|
|
+ tmptext := stext[1 : ei-1]
|
|
|
+ tmptext += end
|
|
|
+ return []rune(tmptext)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { //符号是非成对出现的(将最后一个符号前内容清理掉)
|
|
|
+ i := sIndex[length-1][1]
|
|
|
+ return []rune(stext[i:])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return text
|
|
|
+}
|