(pattern: String, repl: String, string: String)
| 151 | /* sub: replace every match, expanding backreferences in the template. */ |
| 152 | #[plugin_fn] |
| 153 | fn sub(pattern: String, repl: String, string: String) -> Result<String> { |
| 154 | rx(main::sub(&pattern, &repl, &string)) |
| 155 | } |
| 156 | |
| 157 | fn pick(f: &Found, ngroups: usize) -> String { |
| 158 | if ngroups == 1 { f.groups[0].clone().unwrap_or_default() } else { f.text.clone() } |