Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / mvdan.cc / xurls / v2@v2.2.0 / README.md
1 # xurls
2
3 [![GoDoc](https://godoc.org/mvdan.cc/xurls?status.svg)](https://godoc.org/mvdan.cc/xurls)
4
5 Extract urls from text using regular expressions. Requires Go 1.13 or later.
6
7 ```go
8 import "mvdan.cc/xurls/v2"
9
10 func main() {
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") // ""
14
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{}
18 }
19 ```
20
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)
23 for all matches.
24
25 Note that calling the exposed functions means compiling a regular expression, so
26 repeated calls should be avoided.
27
28 #### cmd/xurls
29
30 To install the tool globally:
31
32         cd $(mktemp -d); go mod init tmp; GO111MODULE=on go get mvdan.cc/xurls/v2/cmd/xurls
33
34 ```shell
35 $ echo "Do gophers live in http://golang.org?" | xurls
36 http://golang.org
37 ```