unknown 6 năm trước cách đây
mục cha
commit
d856e88076
2 tập tin đã thay đổi với 8 bổ sung8 xóa
  1. 7 7
      src/jy/clear/specialsymbols.go
  2. 1 1
      src/main_test.go

+ 7 - 7
src/jy/clear/specialsymbols.go

@@ -58,7 +58,7 @@ func init() {
 //去除首尾空格、换行、回车
 //func RemoveHeadAndEndSpace(str) []interface{} {
 func RemoveHeadAndEndSpace(text string) string {
-	qu.Catch()
+	defer qu.Catch()
 	if len(text) > 0 {
 		tmp := cutSpace.ReplaceAllString(strings.Replace(text, " ", " ", -1), "")
 		text = replaceSymbol(tmp, spaces)
@@ -67,10 +67,10 @@ func RemoveHeadAndEndSpace(text string) string {
 }
 
 func RemoveHeadAndEndSymmetricCode(val string) string {
-	qu.Catch()
+	defer qu.Catch()
 	text := []rune(val)
 	if len(text) > 0 {
-		for i := 1; i <= 3; i++ {
+		for i := 1; i <= 2; i++ {
 			if len(text) > 0 {
 				//text = RemoveStart(i, text)
 				text = AnotherRemoveStart(text)
@@ -81,7 +81,7 @@ func RemoveHeadAndEndSymmetricCode(val string) string {
 }
 
 func RemoveStart(i int, text []rune) []rune {
-	qu.Catch()
+	defer qu.Catch()
 	if len(text) > 0 {
 		airedIndex := make(map[int]int)
 		surplusMax := -1  //记录多余的反符号最大值
@@ -190,7 +190,7 @@ func RemoveStart(i int, text []rune) []rune {
 
 //乱码
 func RemoveMessycode(text string) string {
-	qu.Catch()
+	defer qu.Catch()
 	if len(text) > 0 {
 		text = MesReg.ReplaceAllString(text, "")
 	}
@@ -199,7 +199,7 @@ func RemoveMessycode(text string) string {
 
 //特殊符号
 func RemoveAsymmetric(text string) string {
-	qu.Catch()
+	defer qu.Catch()
 	if len(text) > 0 {
 		textRune := []rune(text)
 		first := string(textRune[0])
@@ -228,7 +228,7 @@ func OtherClean(field, text string) string {
 }
 
 func AnotherRemoveStart(text []rune) []rune {
-	qu.Catch()
+	defer qu.Catch()
 	if len(text) > 0 {
 		airedIndex := make(map[int]int)
 		surplusMax := -1  //记录多余的反符号最大值

+ 1 - 1
src/main_test.go

@@ -52,7 +52,7 @@ func Test_paths(t *testing.T) {
 }
 
 func Test_reg3(t *testing.T) {
-	text := []rune("(法撒旦法士大夫发的发生的发的法旦法士大夫三发的)")
+	text := []rune("(法撒旦法士大夫发的发)(]发的法旦法士大夫三发的)")
 	for i := 1; i <= 2; i++ {
 		if len(text) > 0 {
 			text = aa12(i, text)