Documentation
¶
Index ¶
- func Escape(re string) string
- func IsValid(re string) bool
- func IsValidRE2(re string) bool
- func JoinBytes(bytes ...any) []byte
- func TestCache(t *testing.T)
- func TestCompile(t *testing.T)
- func TestConcurrent(t *testing.T)
- func TestFlags(t *testing.T)
- func TestPerformance(t *testing.T)
- func TestReplaceFunc(t *testing.T)
- func TestReplaceStr(t *testing.T)
- func TestReplaceStrComplex(t *testing.T)
- func TestValid(t *testing.T)
- type Regexp
- func (reg *Regexp) Match(buf []byte) bool
- func (reg *Regexp) MatchFile(file *os.File, maxReSize ...int64) bool
- func (reg *Regexp) Rep(buf []byte, rep []byte) []byte
- func (reg *Regexp) RepFile(file *os.File, rep []byte, all bool, maxReSize ...int64) error
- func (reg *Regexp) RepFileFunc(file *os.File, rep func(data func(int) []byte) []byte, all bool, ...) error
- func (reg *Regexp) RepFunc(buf []byte, rep func(b func(int) []byte) []byte) []byte
- func (reg *Regexp) RepLit(str []byte, rep []byte) []byte
- func (reg *Regexp) Split(buf []byte) [][]byte
- func (reg *Regexp) SplitStr(str string) []string
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
func TestCompile ¶
func TestConcurrent ¶
func TestPerformance ¶
func TestReplaceFunc ¶
func TestReplaceStr ¶
func TestReplaceStrComplex ¶
Types ¶
type Regexp ¶
func (*Regexp) Rep ¶
Rep replaces a string with another string
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
func (*Regexp) RepFile ¶
RepFile 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) 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) RepFunc ¶
RepFunc replaces a string with the result of a function
similar to JavaScript .replace(/re/, function(b){})
func (*Regexp) RepLit ¶
RepLit replaces a string with another string literal
note: this function does not accept replacements like $1