This commit is contained in:
2020-05-05 21:33:30 +08:00
parent 80926e99ab
commit 48408e8963

View File

@@ -18,7 +18,7 @@ fn main() {
let re2 = Regex::new(r"(\d+)").unwrap();
println!("{}", re2.replace_all("Hello 100, 200", | caps: &regex::Captures | {
"(".to_owned() + &caps[1] + ")"
"(".to_owned() + &(caps[1].parse::<usize>().unwrap() * 2).to_string() + ")"
}));
println!("{}", re2.replace_all("Hello 100, 200", | caps: &regex::Captures<'_> | {
"[".to_owned() + &caps[1] + "]"