gf: github.com/johng-cn/gf/g/util/gregex Index | Files

package gregex

import "github.com/johng-cn/gf/g/util/gregex"

Package gregex provides high performance API for regular expression functionality.

正则表达式.

Index

Package Files

gregex.go

func IsMatch Uses

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

正则表达式是否匹配

func IsMatchString Uses

func IsMatchString(pattern string, src string) bool

func MatchAllString Uses

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

func MatchString Uses

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

正则匹配,并返回匹配的列表

func Quote Uses

func Quote(s string) string

转移正则规则字符串,例如:Quote(`[foo]`) 返回 `\[foo\]`

func Replace Uses

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

正则替换(全部替换)

func ReplaceFunc Uses

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

正则替换(全部替换),给定自定义替换方法

func ReplaceString Uses

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

正则替换(全部替换),字符串

func ReplaceStringFunc Uses

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

正则替换(全部替换),给定自定义替换方法

func Validate Uses

func Validate(pattern string) error

校验所给定的正则表达式是否符合规范

Package gregex imports 2 packages (graph). Updated 2019-01-16. Refresh now. Tools for package owners.