gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

README.md (1160B)


      1 # xurls
      2 
      3 [![Go Reference](https://pkg.go.dev/badge/mvdan.cc/xurls/v2.svg)](https://pkg.go.dev/mvdan.cc/xurls/v2)
      4 
      5 Extract urls from text using regular expressions. Requires Go 1.19 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 The regular expressions are compiled when the API is first called.
     26 Any subsequent calls will use the same regular expression pointers.
     27 
     28 #### cmd/xurls
     29 
     30 To install the tool globally:
     31 
     32 	go install mvdan.cc/xurls/v2/cmd/xurls@latest
     33 
     34 ```shell
     35 $ echo "Do gophers live in http://golang.org?" | xurls
     36 http://golang.org
     37 ```