gregex

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package gregex provides high performance API for regular expression functionality.

正则表达式.

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>.

判断给定的字符串<src>是否满足正则表达式<pattern>.

func Match

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

MatchString return bytes slice that matched <pattern>.

正则匹配,并返回匹配的列表(参数[]byte)

func MatchAll

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

MatchAll return all bytes slices that matched <pattern>.

正则匹配,并返回所有匹配的列表(参数[]string)

func MatchAllString

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

MatchAllString return all strings that matched <pattern>.

正则匹配,并返回所有匹配的列表(参数[][]string).

func MatchString

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

MatchString return strings that matched <pattern>.

正则匹配,并返回匹配的列表(参数[]string)

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.

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

func Replace

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

ReplaceString 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 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 Split

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

Split slices s 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