Replaces the leftmost-first match with the replacement provided. The replacement can be a regular string (where `$N` and `$name` are expanded to match capture groups) or a function that takes the matches' `Captures` and returns the replaced string. If no match is found, then a copy of the string is returned unchanged. # Replacement string syntax All instances of `$name` in the replacement text
(
&self,
text: &'t str,
rep: R,
)
| 507 | /// # } |
| 508 | /// ``` |
| 509 | pub fn replace<'t, R: Replacer>( |
| 510 | &self, |
| 511 | text: &'t str, |
| 512 | rep: R, |
| 513 | ) -> Cow<'t, str> { |
| 514 | self.replacen(text, 1, rep) |
| 515 | } |
| 516 | |
| 517 | /// Replaces all non-overlapping matches in `text` with the replacement |
| 518 | /// provided. This is the same as calling `replacen` with `limit` set to |