replace_first

Function replace_first 

Source
pub fn replace_first(
    pattern: &str,
    text: &str,
    replacement: &str,
) -> Result<String, String>
Expand description

Replace first match with replacement

§Examples

use ruchy::stdlib::regex;

let result = regex::replace_first(r"\d+", "abc 123 def 456", "X");
assert_eq!(result.unwrap(), "abc X def 456");

§Errors

Returns error if pattern is invalid