PHP » GoLang |
login |
register |
about
|
htmlspecialcharshtmlspecialchars[code=golang] func HtmlSpecialchars(html string) string, { reg,err := regexp.Compile(`<([\w]+)(\s*[\w]+=([\w]+|"[^"]+"))*>([\S\s]*)<[/]?([\w]+)>`) if err != nil { return html } ret := html for reg.MatchString(ret) { ret = reg.ReplaceAllString(ret, "$4") } return ret } [/code] |