gf: github.com/gogf/gf/g/text/gregex Index | Files

package gregex

import "github.com/gogf/gf/g/text/gregex"

Package gregex provides high performance API for regular expression functionality.

Index

Package Files

gregex.go gregex_cache.go

func IsMatch Uses

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

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

func IsMatchString Uses

func IsMatchString(pattern string, src string) bool

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

func Match Uses

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

MatchString return bytes slice that matched <pattern>.

func MatchAll Uses

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

MatchAll return all bytes slices that matched <pattern>.

func MatchAllString Uses

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

MatchAllString return all strings that matched <pattern>.

func MatchString Uses

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

MatchString return strings that matched <pattern>.

func Quote Uses

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 Uses

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

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

func ReplaceFunc Uses

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 Uses

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

ReplaceFunc 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 Uses

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

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

func ReplaceStringFunc Uses

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 Uses

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 Uses

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 Uses

func Validate(pattern string) error

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

Package gregex imports 2 packages (graph) and is imported by 26 packages. Updated 2019-06-25. Refresh now. Tools for package owners.