xurls从纯文本提取 URL

联合创作 · 2023-09-28 14:18

xurls 可以从纯文本中使用正则表达式提取 URL。

go get github.com/mvdan/xurls

使用示例

import "github.com/mvdan/xurls"
func main() {
    xurls.Relaxed.FindString("Do gophers live in golang.org?")
    // "golang.org"
    xurls.Relaxed.FindAllString("foo.com is http://foo.com/.", -1)
    // []string{"foo.com", "http://foo.com/"}
    xurls.Strict.FindAllString("foo.com is http://foo.com/.", -1)
    // []string{"http://foo.com/"}
}
浏览 10
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报