|
@@ -11,6 +11,7 @@ import (
|
11
|
11
|
"github.com/astaxie/beego"
|
12
|
12
|
"github.com/axgle/mahonia"
|
13
|
13
|
"io/ioutil"
|
|
14
|
+ "regexp"
|
14
|
15
|
"strings"
|
15
|
16
|
"syscall"
|
16
|
17
|
"unsafe"
|
|
@@ -555,7 +556,7 @@ func (c *JSybController) GetBasBaseInfo() (string, string) {
|
555
|
556
|
if ret2 != 0 {
|
556
|
557
|
return "", ""
|
557
|
558
|
}
|
558
|
|
- return strings.Replace(string(pCardInfo), " ", "", -1), strings.Replace(string(pBusiCardInfo), " ", "", -1)
|
|
559
|
+ return DeleteExtraSpace(string(pCardInfo)), DeleteExtraSpace(string(pBusiCardInfo))
|
559
|
560
|
}
|
560
|
561
|
|
561
|
562
|
func IntPtr(n int) uintptr {
|
|
@@ -581,3 +582,18 @@ func ConvertToString(src string, srcCode string, tagCode string) string {
|
581
|
582
|
result := string(cdata)
|
582
|
583
|
return result
|
583
|
584
|
}
|
|
585
|
+
|
|
586
|
+func DeleteExtraSpace(s string) string {
|
|
587
|
+ //删除字符串中的多余空格,有多个空格时,仅保留一个空格
|
|
588
|
+ s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
|
|
589
|
+ regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
|
|
590
|
+ reg, _ := regexp.Compile(regstr) //编译正则表达式
|
|
591
|
+ s2 := make([]byte, len(s1)) //定义字符数组切片
|
|
592
|
+ copy(s2, s1) //将字符串复制到切片
|
|
593
|
+ spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
|
|
594
|
+ for len(spc_index) > 0 { //找到适配项
|
|
595
|
+ s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
|
|
596
|
+ spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
|
|
597
|
+ }
|
|
598
|
+ return string(s2)
|
|
599
|
+}
|