gregex

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMatch

func IsMatch(pattern string, src []byte) bool

IsMatch checks whether given bytes <src> matches <pattern>.

func IsMatchString

func IsMatchString(pattern string, src string) bool

IsMatchString checks whether given string <src> matches <pattern>.

func Match

func Match(pattern string, src []byte) ([][]byte, error)

Match return bytes slice that matched <pattern>.

func MatchAll

func MatchAll(pattern string, src []byte) ([][][]byte, error)

MatchAll return all bytes slices that matched <pattern>.

func MatchAllString

func MatchAllString(pattern string, src string) ([][]string, error)

MatchAllString return all strings that matched <pattern>.

func MatchString

func MatchString(pattern string, src string) ([]string, error)

MatchString return strings that matched <pattern>.

func Quote

func Quote(s string) string

Quote quotes <s> by replacing special chars in <s> to match the rules of regular expression pattern. And returns the copy.

Eg: Quote(`[foo]`) returns `\[foo\]`.

func Replace

func Replace(pattern string, replace, src []byte) ([]byte, error)

Replace replace all matched <pattern> in bytes <src> with bytes <replace>.

func ReplaceFunc

func ReplaceFunc(pattern string, src []byte, replaceFunc func(b []byte) []byte) ([]byte, error)

ReplaceFunc replace all matched <pattern> in bytes <src> with custom replacement function <replaceFunc>.

func ReplaceFuncMatch

func ReplaceFuncMatch(pattern string, src []byte, replaceFunc func(match [][]byte) []byte) ([]byte, error)

ReplaceFuncMatch replace all matched <pattern> in bytes <src> with custom replacement function <replaceFunc>. The parameter <match> type for <replaceFunc> is [][]byte, which is the result contains all sub-patterns of <pattern> using Match function.

func ReplaceString

func ReplaceString(pattern, replace, src string) (string, error)

ReplaceString replace all matched <pattern> in string <src> with string <replace>.

func ReplaceStringFunc

func ReplaceStringFunc(pattern string, src string, replaceFunc func(s string) string) (string, error)

ReplaceStringFunc replace all matched <pattern> in string <src> with custom replacement function <replaceFunc>.

func ReplaceStringFuncMatch

func ReplaceStringFuncMatch(pattern string, src string, replaceFunc func(match []string) string) (string, error)

ReplaceStringFuncMatch replace all matched <pattern> in string <src> with custom replacement function <replaceFunc>. The parameter <match> type for <replaceFunc> is []string, which is the result contains all sub-patterns of <pattern> using MatchString function.

func Split

func Split(pattern string, src string) []string

Split slices <src> into substrings separated by the expression and returns a slice of the substrings between those expression matches.

func Validate

func Validate(pattern string) error

Validate checks whether given regular expression pattern <pattern> valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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