rxutil

package
v1.8.72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 2 Imported by: 21

Documentation

Overview

Utilities to make working with regular expressions easier.

Index

Constants

This section is empty.

Variables

View Source
var Integers = regexp.MustCompile(`-?\d+`)
View Source
var Letter = regexp.MustCompile(`[\p{Lu}\p{Ll}]`)
View Source
var Letters = regexp.MustCompile(`[\p{Lu}\p{Ll}]+`)
View Source
var LineBreak = regexp.MustCompile(`(?:\n|\r|\n\r)`)
View Source
var LineBreaks = regexp.MustCompile(`[\n\r]+`)
View Source
var LowerCaseLetter = regexp.MustCompile(`\p{Ll}`)
View Source
var LowerCaseLetters = regexp.MustCompile(`\p{Ll}+`)
View Source
var NonNegativeIntegers = regexp.MustCompile(`\d+`)
View Source
var Numbers = regexp.MustCompile(`-?\d+(?:\.\d+)?`)
View Source
var UpperCaseLetter = regexp.MustCompile(`\p{Lu}`)
View Source
var UpperCaseLetters = regexp.MustCompile(`\p{Lu}+`)
View Source
var Whitespace = regexp.MustCompile(`\s+`)

Functions

func IsMatchString added in v1.7.33

func IsMatchString(pattern interface{}, source string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL