unknown 6 years ago
parent
commit
f430ce714f
2 changed files with 12 additions and 12 deletions
  1. 6 6
      src/jy/clear/specialsymbols.go
  2. 6 6
      src/main_test.go

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

@@ -84,11 +84,11 @@ func RemoveStart(i int, text []rune) []rune {
 	defer qu.Catch()
 	if len(text) > 0 {
 		pairedIndex := make(map[int]int)
-		surplusMax := -1  //记录多余的反符号最大值
-		positiveMax := -1 //记录多余的正符号最大值
+		symbolIndex := make(map[string][]int) //记录符号和当前索引位置
+		surplusMax := -1                      //记录多余的反符号最大值
+		positiveMax := -1                     //记录多余的正符号最大值
 		removeLength := 0
 		length := len(text)
-		symbolIndex := map[string][]int{} //记录符号和当前索引位置
 		for index, t := range text {
 			now := AllReg.FindString(string(t))
 			if len(now) > 0 { //匹配到符号
@@ -231,9 +231,9 @@ func AnotherRemoveStart(text []rune) []rune {
 	defer qu.Catch()
 	if len(text) > 0 {
 		pairedIndex := make(map[int]int)
-		symbolIndex := map[string][]int{} //记录符号和当前索引位置
-		surplusMax := -1                  //记录多余的反符号最大值
-		positiveMax := -1                 //记录多余的正符号最大值
+		symbolIndex := make(map[string][]int) //记录符号和当前索引位置
+		surplusMax := -1                      //记录多余的反符号最大值
+		positiveMax := -1                     //记录多余的正符号最大值
 		removeLength := 0
 		nb := 0
 		length := len(text)

+ 6 - 6
src/main_test.go

@@ -61,7 +61,7 @@ func Test_reg3(t *testing.T) {
 	log.Println("finish--", string(text))
 }
 func aa12(i int, text []rune) []rune {
-	airedIndex := make(map[int]int)
+	pairedIndex := make(map[int]int)
 	surplusMax := -1  //记录多余的反符号最大值
 	positiveMax := -1 //记录多余的正符号最大值
 	removeLength := 0
@@ -105,9 +105,9 @@ func aa12(i int, text []rune) []rune {
 						}
 						//将成对的符号的index记录,
 						if index == length-1 {
-							airedIndex[index] = nowIndex
+							pairedIndex[index] = nowIndex
 						}
-						airedIndex[nowIndex] = index
+						pairedIndex[nowIndex] = index
 					}
 				} else { //正向符号,加入symbolIndex记录索引
 					tmpArr := []int{}
@@ -137,14 +137,14 @@ func aa12(i int, text []rune) []rune {
 			}
 		}
 	}
-	firstOpposite := airedIndex[0]
+	firstOpposite := pairedIndex[0]
 	if firstOpposite != 0 { //第一个正符号对应反符号的位置
 		text = text[firstOpposite+1:]
 		removeLength = firstOpposite + 1
 		nb = nb + removeLength
 	}
-	lastOpposite := airedIndex[length-1] //最后一个符号
-	if lastOpposite > 0 {                //有对称的正向符号,删除其中间内容
+	lastOpposite := pairedIndex[length-1] //最后一个符号
+	if lastOpposite > 0 {                 //有对称的正向符号,删除其中间内容
 		//na = length - lastOpposite
 		text = text[:lastOpposite-removeLength]
 	} else if surplusMax == length-1 { //没有对称,只删除最后一个反符号