Replaces the leftmost-first match with the replacement provided. The replacement can be a regular byte string (where `$N` and `$name` are expanded to match capture groups) or a function that takes the matches' `Captures` and returns the replaced byte string. If no match is found, then a copy of the byte string is returned unchanged. # Replacement string syntax All instances of `$name` in the re
(
&self,
text: &'t [u8],
rep: R,
)
| 460 | /// # } |
| 461 | /// ``` |
| 462 | pub fn replace<'t, R: Replacer>( |
| 463 | &self, |
| 464 | text: &'t [u8], |
| 465 | rep: R, |
| 466 | ) -> Cow<'t, [u8]> { |
| 467 | self.replacen(text, 1, rep) |
| 468 | } |
| 469 | |
| 470 | /// Replaces all non-overlapping matches in `text` with the replacement |
| 471 | /// provided. This is the same as calling `replacen` with `limit` set to |
no test coverage detected