regex

package
v0.0.0-...-cb5ff6d Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LiteralRep

func LiteralRep(rep string) (string, bool)

LiteralRep returns (string,true) if rep is literal, otherwise it returns ("",false)

func Replacement

func Replacement(s, rep string, cap *Captures) string

Replacement makes a single replacement, handling case conversion, &, and \#

Types

type BitSet

type BitSet struct {
	// contains filtered or unexported fields
}

BitSet is a set of int16 stored in bits. Zero value is ready to use. Memory usages depends on the maximum integer value so it should only be used for small values.

func (*BitSet) Add

func (bs *BitSet) Add(n int16)

func (*BitSet) AddNew

func (bs *BitSet) AddNew(n int16) bool

func (*BitSet) Clear

func (bs *BitSet) Clear()

func (*BitSet) Has

func (bs *BitSet) Has(n int16) bool

type Captures

type Captures [20]int32 // 2 * 10 (\0 to \9)

type Pattern

type Pattern string

func Compile

func Compile(rx string) Pattern

Compile converts a regular expression string to a Pattern

func (Pattern) FirstMatch

func (pat Pattern) FirstMatch(s string, i int, cap *Captures) bool

FirstMatch finds the first match at or after position i

func (Pattern) ForEachMatch

func (pat Pattern) ForEachMatch(s string, fn func(cap *Captures) bool)

ForEachMatch calls action for each non-overlapping match in the string. The action should return true to continue, false to stop.

func (Pattern) LastMatch

func (pat Pattern) LastMatch(s string, i int, cap *Captures) bool

LastMatch finds the last match in s. It is less efficient, but rarely used.

func (Pattern) Literal

func (pat Pattern) Literal() (string, bool)

func (Pattern) Match

func (pat Pattern) Match(s string, cap *Captures) bool

Match looks for a match anywhere in the string i.e. not anchored. It returns true if a match was found, and false otherwise. If it returns true, the captures are updated.

func (Pattern) Matches

func (pat Pattern) Matches(s string) bool

Matches is a shortcut for Match(s, nil)

func (Pattern) String

func (pat Pattern) String() string

Jump to

Keyboard shortcuts

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