Эх сурвалжийг харах

更新stringFind方法,text去除空格

maxiaoshan 2 жил өмнө
parent
commit
c9d06e5403
1 өөрчлөгдсөн 4 нэмэгдсэн , 2 устгасан
  1. 4 2
      src/spider/script.go

+ 4 - 2
src/spider/script.go

@@ -762,8 +762,10 @@ func (s *Script) LoadScript(site *string, code, script_file string, newstate boo
 	s.L.SetGlobal("stringFind", s.L.NewFunction(func(S *lua.LState) int {
 		regstr := S.ToString(-1)
 		text := S.ToString(-2)
-		reg := regexp.MustCompile(regstr)
-		result := reg.FindString(text)
+		textReg := regexp.MustCompile(regstr)
+		spaceReg := regexp.MustCompile("[\\s\u3000\u2003\u00a0]+")
+		text = spaceReg.ReplaceAllString(text, "")
+		result := textReg.FindString(text)
 		isMatch := false
 		if result != "" {
 			isMatch = true