正则表达式

    b := []byte("abc1def1")
    pat := `abc1|abc1def1`
    reg1 := regexp.MustCompile(pat)      // 第一匹配
    reg2 := regexp.MustCompilePOSIX(pat) // 最长匹配
    fmt.Printf("%s
", reg1.Find(b))     // abc1
    fmt.Printf("%s
", reg2.Find(b))     // abc1def1
原文地址:https://www.cnblogs.com/pengppp/p/12672078.html