12 lines
401 B
Go
12 lines
401 B
Go
package filter
|
|
|
|
import "regexp"
|
|
|
|
// FilterScriptTags 使用正则表达式过滤 HTML 文本中的 <script> 标签(不区分大小写)
|
|
func FilterScriptTags(input string) string {
|
|
// 正则表达式匹配 <script> 标签及其内容,不区分大小写
|
|
re := regexp.MustCompile(`(?i)<script[^>]*>.*?</script>`)
|
|
// 替换匹配的部分为空字符串
|
|
return re.ReplaceAllString(input, "")
|
|
}
|