Documentation ¶
Index ¶
- func Escape(re string) string
- func IsValid(re string) bool
- func IsValidRE2(re string) bool
- func JoinBytes(bytes ...interface{}) []byte
- type RE2
- type Regexp
- func (reg *Regexp) Match(str []byte) bool
- func (reg *Regexp) RepFileFunc(name string, rep func(data func(int) []byte) []byte, all bool, ...) error
- func (reg *Regexp) RepFileStr(name string, rep []byte, all bool, maxReSize ...int64) error
- func (reg *Regexp) RepFunc(str []byte, rep func(data func(int) []byte) []byte, blank ...bool) []byte
- func (reg *Regexp) RepStr(str []byte, rep []byte) []byte
- func (reg *Regexp) RepStrLit(str []byte, rep []byte) []byte
- func (reg *Regexp) Split(str []byte) [][]byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidRE2 ¶
IsValidRE2 will return true if a regex is valid and can be compiled by the builtin RE2 module
Types ¶
type Regexp ¶
func (*Regexp) RepFileFunc ¶ added in v2.1.2
func (reg *Regexp) RepFileFunc(name string, rep func(data func(int) []byte) []byte, all bool, maxReSize ...int64) error
RepFileFunc replaces a regex match with the result of a callback function in a file
@all: if true, will replace all text matching @re, if false, will only replace the first occurrence
func (*Regexp) RepFileStr ¶ added in v2.1.2
RepFileStr replaces a regex match with a new []byte in a file
@all: if true, will replace all text matching @re, if false, will only replace the first occurrence
func (*Regexp) RepFunc ¶
func (reg *Regexp) RepFunc(str []byte, rep func(data func(int) []byte) []byte, blank ...bool) []byte
RepFunc replaces a string with the result of a function
similar to JavaScript .replace(/re/, function(data){})
func (*Regexp) RepStr ¶
RepStr is a more complex version of the RepStrLit method
this function will replace things in the result like $1 with your capture groups
use $0 to use the full regex capture group
use ${123} to use numbers with more than one digit