Documentation
¶
Overview ¶
Package goodregex provides a collection of pre-compiled regular expressions for matching IPv4 addresses, IPv6 addresses, and hostnames.
It also provides CompileReadableRegex and MustCompileReadableRegex, which accept "readable regexes" -- regular RE2 expressions with embedded whitespace and comments for human readability.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MatchBoundedHostname = MustCompileReadableRegex(`(?:\b` + regexMatchHostname + `\b)`)
MatchBoundedHostname is an experimental version of MatchHostname that only matches if the hostname is surrounded by a word border.
var MatchBoundedIPv4 = MustCompileReadableRegex(`(?:\b` + regexMatchV4 + `\b)`)
MatchBoundedIPv4 is an experimental version of MatchIPv4 that only matches if the IPv4 address is surrounded by a word border.
var MatchHostname = MustCompileReadableRegex(regexMatchHostname)
MatchHostname matches a hostname according to RfC 1123 2.1
var MatchIPv4 = MustCompileReadableRegex(regexMatchV4)
MatchIPv4 matches IPv4 addresses in dotted decimal notation
var MatchIPv6 = MustCompileReadableRegex(regexMatchV6)
MatchIPv6 matches IPv6 addresses. It supports colon-separated hexadecimal notation including ::-abbreviation, IPv4-embedded IPv6 addresses and IPv4-Mapped IPv6 Address. The unspecified address "::" is not matched as it cannot be resolved or connected to.
Functions ¶
func CompileReadableRegex ¶
CompileReadableRegex is similar to regexp.Compile. It accepts a "readable regex" which is a regular RE2 regexp where whitespace and comments (a # followed by everything until the end of line) are removed prior to compilation.
func MustCompileReadableRegex ¶
MustCompileReadableRegex is similar to regexp.MustCompile. It accepts a "readable regex" which is a regular RE2 regexp where whitespace and comments (a # followed by everything until the end of line) are removed prior to compilation. It panics if the expression cannot be parsed.
Types ¶
This section is empty.