正则表达式,提前内容
2018-08-24 本文已影响0人
次序
package main
import (
"regexp"
"fmt"
)
const text = `My email is ccmouse@gmail.com
email1 is ac@def.rog
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.]+)`)
math := re.FindAllStringSubmatch(text,-1)
for _,m:=range math {
fmt.Println(m)
}
}