当年话下
package mainimport ("fmt""regexp")func main() {s := "John: 2578.34 William: 4567.23 Steve: 5632.18"pattern := "[0-9]+\\.[0-9]+" //模式if ok, _ := regexp.MatchString(pattern, s); ok {fmt.Println("匹配到了")}reg, _ := regexp.Compile(pattern)all := reg.FindAllString(s, -1)fmt.Println(all)fmt.Println(len(all))}