regex

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(re string) string

Escape will escape regex special chars

func IsValid added in v4.2.0

func IsValid(str []byte) bool

func IsValidPointer added in v4.2.0

func IsValidPointer(str *[]byte) bool

func JoinBytes

func JoinBytes(bytes ...interface{}) []byte

JoinBytes is an easy way to join multiple values into a single []byte accepts: []byte, byte, int32, string, [][]byte, int, int64, float64, float32

Types

type PCRE

type PCRE = pcre.Regexp

type Regexp

type Regexp struct {
	RE *pcre.Regexp
}

func Compile

func Compile(re string, params ...string) *Regexp

Compile compiles a regular expression and store it in the cache

func (*Regexp) Match

func (reg *Regexp) Match(str []byte) bool

Match returns true if a []byte matches a regex

func (*Regexp) MatchPointer

func (reg *Regexp) MatchPointer(str *[]byte) bool

MatchRef returns true if a string matches a regex Uses Pointers For Improved Performance

func (*Regexp) ReplaceFunc

func (reg *Regexp) ReplaceFunc(str []byte, rep func(data func(int) []byte) []byte, blank ...bool) []byte

RepFunc replaces a string with the result of a function similar to JavaScript .replace(/re/, function(data){})

func (*Regexp) ReplaceFuncFirst

func (reg *Regexp) ReplaceFuncFirst(str []byte, rep func(func(int) []byte) []byte, blank ...bool) []byte

RepFuncFirst is a copy of the RepFunc method modified to only run once

func (*Regexp) ReplaceFuncPointer

func (reg *Regexp) ReplaceFuncPointer(str *[]byte, rep func(data func(int) []byte) []byte, blank ...bool) []byte

RepFuncRef replace a string with the result of a function similar to JavaScript .replace(/re/, function(data){}) Uses Pointers For Improved Performance

func (*Regexp) ReplaceString

func (reg *Regexp) ReplaceString(str []byte, rep []byte) []byte

RepStr replaces a string with another string note: this function is optimized for performance, and the replacement string does not accept replacements like $1

func (*Regexp) ReplaceStringComplex

func (reg *Regexp) ReplaceStringComplex(str []byte, rep []byte) []byte

RepStrComplex is a more complex version of the RepStr method this function will replace things in the result like $1 with your capture groups use $0 to use the full regex capture group use ${123} to use numbers with more than one digit

func (*Regexp) ReplaceStringComplexPointer

func (reg *Regexp) ReplaceStringComplexPointer(str *[]byte, rep []byte) []byte

RepStrComplexRef is a more complex version of the RepStrRef method this function will replace things in the result like $1 with your capture groups use $0 to use the full regex capture group use ${123} to use numbers with more than one digit Uses Pointers For Improved Performance

func (*Regexp) ReplaceStringComplexPointerWithResultPointer

func (reg *Regexp) ReplaceStringComplexPointerWithResultPointer(str *[]byte, rep *[]byte) []byte

RepStrComplexRefRes is a more complex version of the RepStrRefRes method this function will replace things in the result like $1 with your capture groups use $0 to use the full regex capture group use ${123} to use numbers with more than one digit Uses Pointers For Improved Performance (also on result)

func (*Regexp) ReplaceStringPointer

func (reg *Regexp) ReplaceStringPointer(str *[]byte, rep []byte) []byte

RepStrRef replaces a string with another string note: this function is optimized for performance, and the replacement string does not accept replacements like $1 Uses Pointers For Improved Performance

func (*Regexp) ReplaceStringPointerWithResultPointer

func (reg *Regexp) ReplaceStringPointerWithResultPointer(str *[]byte, rep *[]byte) []byte

RepStrRefRes replaces a string with another string note: this function is optimized for performance, and the replacement string does not accept replacements like $1 Uses Pointers For Improved Performance (also on result)

func (*Regexp) Split

func (reg *Regexp) Split(str []byte) [][]byte

Split splits a string, and keeps capture groups Similar to JavaScript .split(/re/)

func (*Regexp) SplitPointer

func (reg *Regexp) SplitPointer(str *[]byte) [][]byte

SplitRef splits a string, and keeps capture groups Similar to JavaScript .split(/re/) Uses Pointers For Improved Performance

Jump to

Keyboard shortcuts

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