Documentation ¶
Overview ¶
Package xurls extracts urls from plain text using regular expressions.
Example ¶
package main import ( "fmt" "github.com/mvdan/xurls" ) func main() { fmt.Println(xurls.Relaxed.FindString("Do gophers live in http://golang.org?")) fmt.Println(xurls.Relaxed.FindAllString("foo.com is http://foo.com/.", -1)) }
Output: http://golang.org [foo.com http://foo.com/]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Relaxed matches all the urls it can find. Relaxed = regexp.MustCompile(relaxed) // Strict only matches urls with a scheme to avoid false positives. Strict = regexp.MustCompile(strict) )
View Source
var PseudoTLDs = []string{
`bit`,
`example`,
`exit`,
`gnu`,
`i2p`,
`invalid`,
`local`,
`localhost`,
`test`,
`zkey`,
}
PseudoTLDs is a sorted list of some widely used unofficial TLDs.
Sources:
- https://en.wikipedia.org/wiki/Pseudo-top-level_domain
- https://en.wikipedia.org/wiki/Category:Pseudo-top-level_domains
- https://tools.ietf.org/html/draft-grothoff-iesg-special-use-p2p-names-00
- https://www.iana.org/assignments/special-use-domain-names/special-use-domain-names.xhtml
View Source
var SchemesNoAuthority = []string{
`bitcoin`,
`file`,
`magnet`,
`mailto`,
`sms`,
`tel`,
`xmpp`,
}
SchemesNoAuthority is a sorted list of some well-known url schemes that are followed by ":" instead of "://". Since these are more prone to false positives, we limit their matching.
View Source
var TLDs = []string{}/* 1554 elements not displayed */
TLDs is a sorted list of all public top-level domains.
Sources:
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.