Documentation ¶
Overview ¶
Package gregex provides high performance API for regular expression functionality.
正则表达式.
Index ¶
- func IsMatch(pattern string, src []byte) bool
- func IsMatchString(pattern string, src string) bool
- func Match(pattern string, src []byte) ([][]byte, error)
- func MatchAll(pattern string, src []byte) ([][][]byte, error)
- func MatchAllString(pattern string, src string) ([][]string, error)
- func MatchString(pattern string, src string) ([]string, error)
- func Quote(s string) string
- func Replace(pattern string, replace, src []byte) ([]byte, error)
- func ReplaceFunc(pattern string, src []byte, replaceFunc func(b []byte) []byte) ([]byte, error)
- func ReplaceString(pattern, replace, src string) (string, error)
- func ReplaceStringFunc(pattern string, src string, replaceFunc func(s string) string) (string, error)
- func Split(pattern string, src string) []string
- func Validate(pattern string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMatchString ¶
IsMatchString checks whether given string <src> matches <pattern>.
判断给定的字符串<src>是否满足正则表达式<pattern>.
func MatchAll ¶
MatchAll return all bytes slices that matched <pattern>.
正则匹配,并返回所有匹配的列表(参数[]string)
func MatchAllString ¶
MatchAllString return all strings that matched <pattern>.
正则匹配,并返回所有匹配的列表(参数[][]string).
func Quote ¶
Quote quotes <s> by replacing special chars in <s> to match the rules of regular expression pattern. And returns the copy.
转移正则规则字符串,例如:Quote(`[foo]`) 返回 `\[foo\]`
func Replace ¶
ReplaceString replace all matched <pattern> in bytes <src> with bytes <replace>.
正则替换(全部替换).
func ReplaceFunc ¶
ReplaceFunc replace all matched <pattern> in bytes <src> with custom replacement function <replaceFunc>.
正则替换(全部替换),给定自定义替换方法
func ReplaceString ¶
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>.
正则替换(全部替换),给定自定义替换方法
Types ¶
This section is empty.