MCPcopy
hub / github.com/bitfield/script / ReplaceRegexp

Method ReplaceRegexp

script.go:846–850  ·  view source on GitHub ↗

ReplaceRegexp replaces all matches of the compiled regexp re with the string replace. $x variables in the replace string are interpreted as by [regexp#Regexp.Expand]; for example, $1 represents the text of the first submatch.

(re *regexp.Regexp, replace string)

Source from the content-addressed store, hash-verified

844// replace. $x variables in the replace string are interpreted as by
845// [regexp#Regexp.Expand]; for example, $1 represents the text of the first submatch.
846func (p *Pipe) ReplaceRegexp(re *regexp.Regexp, replace string) *Pipe {
847 return p.FilterLine(func(line string) string {
848 return re.ReplaceAllString(line, replace)
849 })
850}
851
852// Read reads up to len(b) bytes from the pipe into b. It returns the number of
853// bytes read and any error encountered. At end of file, or on a nil pipe, Read

Calls 1

FilterLineMethod · 0.95