replace_phone_numbers_in_text

Function replace_phone_numbers_in_text 

Source
pub fn replace_phone_numbers_in_text<F>(text: &str, replacement: F) -> String
Expand description

Replace phone numbers in text with a placeholder or transformed version

§Arguments

  • text - The text containing phone numbers
  • replacement - Function that takes an ExtractedPhoneNumber and returns the replacement string

§Returns

  • String - The text with phone numbers replaced

§Examples

use phonelib::replace_phone_numbers_in_text;
 
let text = "Call me at +12025550173";
let redacted = replace_phone_numbers_in_text(text, |_| "[REDACTED]".to_string());
assert_eq!(redacted, "Call me at [REDACTED]");