3 [![GoDoc](https://godoc.org/mvdan.cc/xurls?status.svg)](https://godoc.org/mvdan.cc/xurls)
5 Extract urls from text using regular expressions. Requires Go 1.13 or later.
8 import "mvdan.cc/xurls/v2"
11 rxRelaxed := xurls.Relaxed()
12 rxRelaxed.FindString("Do gophers live in golang.org?") // "golang.org"
13 rxRelaxed.FindString("This string does not have a URL") // ""
15 rxStrict := xurls.Strict()
16 rxStrict.FindAllString("must have scheme: http://foo.com/.", -1) // []string{"http://foo.com/"}
17 rxStrict.FindAllString("no scheme, no match: foo.com", -1) // []string{}
21 Since API is centered around [regexp.Regexp](https://golang.org/pkg/regexp/#Regexp),
22 many other methods are available, such as finding the [byte indexes](https://golang.org/pkg/regexp/#Regexp.FindAllIndex)
25 Note that calling the exposed functions means compiling a regular expression, so
26 repeated calls should be avoided.
30 To install the tool globally:
32 cd $(mktemp -d); go mod init tmp; GO111MODULE=on go get mvdan.cc/xurls/v2/cmd/xurls
35 $ echo "Do gophers live in http://golang.org?" | xurls