|
@@ -12354,3 +12354,18 @@ func (c *HisApiController) GetELeCertInfo(code string, operator_id string, opera
|
12354
|
12354
|
}
|
12355
|
12355
|
return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
|
12356
|
12356
|
}
|
|
12357
|
+
|
|
12358
|
+func DeleteExtraSpace(s string) string {
|
|
12359
|
+ //删除字符串中的多余空格,有多个空格时,仅保留一个空格
|
|
12360
|
+ s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
|
|
12361
|
+ regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
|
|
12362
|
+ reg, _ := regexp.Compile(regstr) //编译正则表达式
|
|
12363
|
+ s2 := make([]byte, len(s1)) //定义字符数组切片
|
|
12364
|
+ copy(s2, s1) //将字符串复制到切片
|
|
12365
|
+ spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
|
|
12366
|
+ for len(spc_index) > 0 { //找到适配项
|
|
12367
|
+ s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
|
|
12368
|
+ spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
|
|
12369
|
+ }
|
|
12370
|
+ return string(s2)
|
|
12371
|
+}
|