``` package main import ( "fmt" "regexp" ) func main() { // 验证 fmt.Println(regexp.MatchString("我是(\\S+)==", "我是于晓波==")) // 替换 src := string("hello, japanese===!") r, _ := regexp.Compile("ese([=]*)!") fmt.Println(r.ReplaceAllString(src, "woc!$1")) // 匹配子字符 src = "hgfyusgf13864hgjyjgsfg4554jhagfhe8818sfg" r, _ = regexp.Compile("(\\d+)") fmt.Println(r.FindAllString(src, -1)[2]) // 参考资料: https://www.kancloud.cn/kancloud/web-application-with-golang/44184 } ```