xurls

Extract urls from text

  • Owner: mvdan/xurls
  • Platform:
  • License:: BSD 3-Clause "New" or "Revised" License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

xurls

GoDoc

Extract urls from text using regular expressions. Requires Go 1.12 or later.

import "mvdan.cc/xurls/v2"

func main() {
	rxRelaxed := xurls.Relaxed()
	rxRelaxed.FindString("Do gophers live in golang.org?")  // "golang.org"
	rxRelaxed.FindString("This string does not have a URL") // ""

	rxStrict := xurls.Strict()
	rxStrict.FindAllString("must have scheme: http://foo.com/.", -1) // []string{"http://foo.com/"}
	rxStrict.FindAllString("no scheme, no match: foo.com", -1)       // []string{}
}

Note that the funcs compile regexes, so avoid calling them repeatedly.

cmd/xurls

To install the tool globally:

cd $(mktemp -d); go mod init tmp; GO111MODULE=on go get mvdan.cc/xurls/v2/cmd/xurls
$ echo "Do gophers live in http://golang.org?", xurls
http://golang.org

Main metrics

Overview
Name With Ownermvdan/xurls
Primary LanguageGo
Program languageGo (Language Count: 1)
Platform
License:BSD 3-Clause "New" or "Revised" License
所有者活动
Created At2015-01-12 01:28:46
Pushed At2025-02-22 14:31:19
Last Commit At2025-02-22 14:31:16
Release Count21
Last Release Namev2.6.0 (Posted on 2025-01-02 16:56:14)
First Release Namev0.1 (Posted on 2015-01-31 18:17:14)
用户参与
Stargazers Count1.2k
Watchers Count23
Fork Count117
Commits Count452
Has Issues Enabled
Issues Count55
Issue Open Count1
Pull Requests Count19
Pull Requests Open Count1
Pull Requests Close Count7
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private