Documentation
¶
Index ¶
- func Escape(re string) string
- func IsValid(re string) bool
- func IsValidPCRE(re string) bool
- func IsValidRE2(re string) bool
- func JoinBytes(bytes ...interface{}) []byte
- type PCRE
- type RE2
- type Regexp
- func (reg *Regexp) Match(str []byte) bool
- func (reg *Regexp) MatchFile(file *os.File, maxReSize ...int64) bool
- func (reg *Regexp) RepFileFunc(file *os.File, rep func(data func(int) []byte) []byte, all bool, ...) error
- func (reg *Regexp) RepFileStr(file *os.File, rep []byte, all bool, maxReSize ...int64) error
- func (reg *Regexp) RepFunc(str []byte, rep func(data func(int) []byte) []byte) []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
- type RegexpRE2
- func (reg *RegexpRE2) Match(str []byte) bool
- func (reg *RegexpRE2) MatchFile(file *os.File, maxReSize ...int64) bool
- func (reg *RegexpRE2) RepFileFunc(file *os.File, rep func(data func(int) []byte) []byte, all bool, ...) error
- func (reg *RegexpRE2) RepFileStr(file *os.File, rep []byte, all bool, maxReSize ...int64) error
- func (reg *RegexpRE2) RepFunc(str []byte, rep func(data func(int) []byte) []byte, blank ...bool) []byte
- func (reg *RegexpRE2) RepStr(str []byte, rep []byte) []byte
- func (reg *RegexpRE2) RepStrLit(str []byte, rep []byte) []byte
- func (reg *RegexpRE2) Split(str []byte) [][]byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidPCRE ¶
IsValidPCRE will return true if a regex is valid and can be compiled by the PCRE module
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 ¶
func (reg *Regexp) RepFileFunc(file *os.File, 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 ¶
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 ¶
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
type RegexpRE2 ¶
func CompTryRE2 ¶
CompTryRE2 tries to compile re2 or returns an error
func (*RegexpRE2) MatchFile ¶ added in v0.1.0
MatchFile returns true if a file contains a regex match
func (*RegexpRE2) RepFileFunc ¶
func (reg *RegexpRE2) RepFileFunc(file *os.File, 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 (*RegexpRE2) RepFileStr ¶
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 (*RegexpRE2) RepFunc ¶
func (reg *RegexpRE2) 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 (*RegexpRE2) 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