rxutil

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: MIT Imports: 2 Imported by: 21

Documentation

Overview

Utilities to make working with regular expressions easier.

Index

Constants

This section is empty.

Variables

This section is empty.

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