|
il y a 5 ans | |
---|---|---|
.. | ||
.gitignore | il y a 5 ans | |
.travis.yml | il y a 5 ans | |
BUILD | il y a 5 ans | |
LICENSE | il y a 5 ans | |
README.md | il y a 5 ans | |
regex.go | il y a 5 ans | |
schemes.go | il y a 5 ans | |
tlds.go | il y a 5 ans | |
tlds_pseudo.go | il y a 5 ans | |
xurls.go | il y a 5 ans |
Extract urls from text using regular expressions.
go get github.com/mvdan/xurls
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/"}
}
Reads text and prints one url per line.
go get github.com/mvdan/xurls/cmd/xurls
$ echo "Do gophers live in http://golang.org?" | xurls
http://golang.org