-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Description
by itcraft.letter:
Package regexp: http://golang.org/pkg/regexp/ bad specification of functions: -- func (re *Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte func (re *Regexp) ReplaceAllStringFunc(src string, repl func(string) string) string -- correct specification of functions: -- func (re *Regexp) ReplaceAllFunc(src []byte, repl func([][]byte) []byte) []byte func (re *Regexp) ReplaceAllStringFunc(src string, repl func([]string) string) string -- It is necessary to transfer in the function of the parts of regexp. Example reg := regexp.MustCompile(`#{(\w*)}#`) replacer := func(partRegExp []string) string { //{$0} - partRegExp[0] //{$1} - partRegExp[1] // ... } fileSource = reg.ReplaceAllStringFunc(fileSource, replacer)