summaryrefslogtreecommitdiffstats
path: root/vendor/mvdan.cc/xurls/v2/README.md
blob: 5058efe7a7944f810b89ad2dab0419d799f92aa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# xurls

[![GoDoc](https://godoc.org/mvdan.cc/xurls?status.svg)](https://godoc.org/mvdan.cc/xurls)
[![Travis](https://travis-ci.org/mvdan/xurls.svg?branch=master)](https://travis-ci.org/mvdan/xurls)

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

```go
import "mvdan.cc/xurls/v2"

func main() {
	xurls.Relaxed().FindString("Do gophers live in golang.org?")
	// "golang.org"
	xurls.Strict().FindAllString("foo.com is http://foo.com/.", -1)
	// []string{"http://foo.com/"}
}
```

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

#### cmd/xurls

	go get -u mvdan.cc/xurls/v2/cmd/xurls

```shell
$ echo "Do gophers live in http://golang.org?" | xurls
http://golang.org
```