From 39282413cfa402edbbe6a93e2ab4fecdb64c174b Mon Sep 17 00:00:00 2001 From: _Fighter Date: Thu, 18 Aug 2022 23:30:59 +0800 Subject: [PATCH] =?UTF-8?q?8=E6=9C=888=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- regex/regex.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/regex/regex.go b/regex/regex.go index 3e4cfe4..59251b7 100644 --- a/regex/regex.go +++ b/regex/regex.go @@ -1,5 +1,25 @@ package main +import ( + "fmt" + "regexp" +) + +const text = `my email is wewfw@hdf.com + mail1 fwefwe@efw.com.cn + mail2 test@qq.com.cn` + func main() { - $END$ + + /*re2 ,_:= regexp.Compile(`[a-zA-Z0-9]+@[a-zA-Z0-9.]+\.[a-zA-Z0-9]+`) + findString := re2.FindAllString(text,-1) + fmt.Println(findString)*/ + re := regexp.MustCompile(`([a-zA-Z0-9]+)@([a-zA-Z0-9]+)\.([a-zA-Z0-9.]+)`) + + //allString := re.FindAllString(text, -1) + submatch := re.FindAllStringSubmatch(text, -1) + for _, m := range submatch { + fmt.Println(m) + } + } -- GitLab