mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-19 06:29:00 +00:00
godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
32 lines
823 B
Markdown
32 lines
823 B
Markdown
# xurls
|
|
|
|
[](https://godoc.org/github.com/mvdan/xurls) [](https://travis-ci.org/mvdan/xurls)
|
|
|
|
Extract urls from text using regular expressions.
|
|
|
|
go get github.com/mvdan/xurls
|
|
|
|
```go
|
|
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/"}
|
|
}
|
|
```
|
|
|
|
#### cmd/xurls
|
|
|
|
Reads text and prints one url per line.
|
|
|
|
go get github.com/mvdan/xurls/cmd/xurls
|
|
|
|
```shell
|
|
$ echo "Do gophers live in http://golang.org?" | xurls
|
|
http://golang.org
|
|
```
|