Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate regex;
- use regex::Regex;
- use std::borrow::Cow;
- fn main() {
- let out = do_regex("hello foo");
- println!("{}", out);
- }
- fn do_regex<'a>(txt: &'a str) -> Cow<str> {
- let rx = Regex::new("foo").unwrap();
- let out = rx.replace_all(txt, "bar");
- let out2 = rx.replace_all(&out, "blah");
- out2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement