Replace uses Regexp to find any matched from `input` with `regexpTerm` and replaces them with `replaceTerm` then returns new string.
(str *string, pattern string, repl func(submatches ...string) string)
| 165 | // Replace uses Regexp to find any matched from `input` with `regexpTerm` |
| 166 | // and replaces them with `replaceTerm` then returns new string. |
| 167 | func Replace(str *string, pattern string, repl func(submatches ...string) string) { |
| 168 | re := regexp.MustCompile(pattern) |
| 169 | *str = re.ReplaceAllStringFunc(*str, func(match string) string { |
| 170 | submatches := re.FindStringSubmatch(match) |
| 171 | return repl(submatches...) |
| 172 | }) |
| 173 | } |
| 174 | |
| 175 | func ReplaceOnce(str *string, pattern string, repl func(submatches ...string) string) { |
| 176 | re := regexp.MustCompile(pattern) |
no outgoing calls
no test coverage detected