diff --git a/zh/07.3.md b/zh/07.3.md index 753c28ea6..7db76694f 100644 --- a/zh/07.3.md +++ b/zh/07.3.md @@ -75,23 +75,29 @@ func main() { src := string(body) //将HTML标签全转换成小写 - re, _ := regexp.Compile("\\<[\\S\\s]+?\\>") + re, _ := regexp.Compile(`<[\S\s]+?>`) src = re.ReplaceAllStringFunc(src, strings.ToLower) //去除STYLE - re, _ = regexp.Compile("\\") + re, _ = regexp.Compile(``) + src = re.ReplaceAllString(src, "") + //去除HTMLUnscape的STYLE + re, _ = regexp.Compile(`<style[\S\s]+?</style>`) src = re.ReplaceAllString(src, "") //去除SCRIPT - re, _ = regexp.Compile("\\") + re, _ = regexp.Compile(``) + src = re.ReplaceAllString(src, "") + //去除HTMLUnsapce的SCRIPT + re, _ = regexp.Compile(`<script[\S\s]+?</script>`) src = re.ReplaceAllString(src, "") //去除所有尖括号内的HTML代码,并换成换行符 - re, _ = regexp.Compile("\\<[\\S\\s]+?\\>") + re, _ = regexp.Compile(`<[\S\s]+?>`) src = re.ReplaceAllString(src, "\n") //去除连续的换行符 - re, _ = regexp.Compile("\\s{2,}") + re, _ = regexp.Compile(`\s{2,}`) src = re.ReplaceAllString(src, "\n") fmt.Println(strings.TrimSpace(src))