|
@@ -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 { //没有对称,只删除最后一个反符号
|