package main
import (
"fmt"
"regexp"
)
const text = `
My email is 8899666@qq.com
email1 is abc@def.org
email2 is kkk@qq.com
email3 is ddd@abc.com.cn
`
func main() {
//确定要寻找的目标及返回需要的字符段
re := regexp.MustCompile(`([a-zA-Z0-9]+)@([a-zA-Z0-9]+)(\.[a-zA-Z0-9.]+)`)
//返回二维数组 函数的作用是得到字符段并按要求返回需要的单个字符串
match := re.FindAllStringSubmatch(text,-1)
//循环打印每一段字符
for _, m := range match{
fmt.Println(m)
}
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询