Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

regex to find and replace values

extern crate regex;
use regex::Regex;

fn main() {
// Find, extract, replace dates in text
let re = Regex::new(r"(?x)
  (?P<yyyy>d{4})-(?P<mm>d{2})-(?P<dd>d{2})").unwrap();
let before = "The dates are 2020-04-13, 2021-07-23 and 2019-05-07";
let after = re.replace_all(before, "$dd/$mm/$yyyy");
println!("Before: {}", before);
println!("After:  {}", after);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #regex #find #replace #values
ADD COMMENT
Topic
Name
2+3 =