dregex

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMatch added in v0.0.3

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

IsMatch 是否匹配

func IsMatchString added in v0.0.3

func IsMatchString(pattern string, src string) bool

IsMatchString 字符串是否匹配

func Match

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

Match 返回匹配的byte数组

func MatchAll added in v0.1.9

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

MatchAll 以slice返回匹配的所有数据

func MatchAllString added in v0.1.9

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 返回<pattern>匹配的字符串

func Quote

func Quote(s string) string

Quote 对<s>中的特殊字符加引号,并返回副本 Eg: Quote(`[foo]`) returns `\[foo\]`.

func Replace added in v0.0.3

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

Replace 使用正则匹配替换

func ReplaceFunc

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

ReplaceFunc 使用自定义func按照规则替换数据

func ReplaceFuncMatch added in v0.1.9

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 added in v0.0.3

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

ReplaceString 使用正则匹配替换字符串

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 added in v0.1.9

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 added in v0.1.9

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 验证正则表达式规则是否合法

Types

This section is empty.

Jump to

Keyboard shortcuts

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