github.com/pubgo/regex
    github.com/mingrammer/commonregex
    https://darjun.github.io/2020/09/05/godailylib/commonregex

    它提供了这些作为获取与特定模式对应的匹配字符串的简单函数。

    • 日期
    • 时间
    • 电话号码
    • 超链接
    • 邮件地址
    • IPv4/IPv6/IP 地址
    • 价格
    • 十六进制颜色值
    • 信用卡卡号
    • 10/13 位 ISBN
    • 邮政编码
    • MD5
    • SHA1
    • SHA256
    • GUID,全局唯一标识
    • Git 仓库地址
    1. package main
    2. import (
    3. "fmt"
    4. cregex "github.com/mingrammer/commonregex"
    5. )
    6. func main() {
    7. text := `John, please get that article on www.linkedin.com to me by 5:00PM on Jan 9th 2012. 4:00 would be ideal, actually. If you have any questions, You can reach me at (519)-236-2723x341 or get in touch with my associate at harold.smith@gmail.com`
    8. dateList := cregex.Date(text)
    9. timeList := cregex.Time(text)
    10. linkList := cregex.Links(text)
    11. phoneList := cregex.PhonesWithExts(text)
    12. emailList := cregex.Emails(text)
    13. fmt.Println("date list:", dateList)
    14. fmt.Println("time list:", timeList)
    15. fmt.Println("link list:", linkList)
    16. fmt.Println("phone list:", phoneList)
    17. fmt.Println("email list:", emailList)
    18. }