Documentation ¶
Overview ¶
Utilities to make working with regular expressions easier.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Integers = regexp.MustCompile(`-?\d+`)
var Letter = regexp.MustCompile(`[\p{Lu}\p{Ll}]`)
var Letters = regexp.MustCompile(`[\p{Lu}\p{Ll}]+`)
var LineBreak = regexp.MustCompile(`(?:\n|\r|\n\r)`)
var LineBreaks = regexp.MustCompile(`[\n\r]+`)
var LowerCaseLetter = regexp.MustCompile(`\p{Ll}`)
var LowerCaseLetters = regexp.MustCompile(`\p{Ll}+`)
var NonNegativeIntegers = regexp.MustCompile(`\d+`)
var Numbers = regexp.MustCompile(`-?\d+(?:\.\d+)?`)
var UpperCaseLetter = regexp.MustCompile(`\p{Lu}`)
var UpperCaseLetters = regexp.MustCompile(`\p{Lu}+`)
var Whitespace = regexp.MustCompile(`\s+`)
Functions ¶
func IsMatchString ¶ added in v1.7.33
Types ¶
type MatchResult ¶
type MatchResult struct {
// contains filtered or unexported fields
}
func Match ¶
func Match(pattern interface{}, source string) *MatchResult
Returns a MatchResult object representing the leftmost match of pattern against source, or nil if no matches were found. Pattern can be a string or a previously-compiled *regexp.Regexp.
func (*MatchResult) AllCaptures ¶
func (self *MatchResult) AllCaptures() []string
Returns all captures from all matches appended together. The full match string from match is omitted, so only the actual values appearing within capture groups are returned.
func (*MatchResult) Captures ¶
func (self *MatchResult) Captures() []string
Return a slice of all capture groups.
func (*MatchResult) Group ¶
func (self *MatchResult) Group(nameOrIndex interface{}) string
Return the value of the numbered capture group (if given an int), or the named capture group (if given a string). Returns an empty string if the given group name or index does not exist.
func (*MatchResult) NamedCaptures ¶
func (self *MatchResult) NamedCaptures() map[string]string
Returns a map of all named capture matches, keyed on capture group name.
func (*MatchResult) ReplaceGroup ¶
func (self *MatchResult) ReplaceGroup(nameOrIndex interface{}, repl string) string
Return a copy of source string with the given numbered or named group replaced with repl.