// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)^$\n(^$\n)*").unwrap();
let string = "Nunc scelerisque risus lectus, id ultricies nulla vulputate eu.
Quisque fermentum pretium pharetra. Etiam nec felis diam.
Curabitur pretium suscipit ex sed pulvinar.
In interdum eget massa sed posuere.
Aliquam rutrum auctor tempor.
Praesent sodales eu massa rhoncus efficitur.
Proin egestas non erat vitae feugiat. Suspendisse rutrum placerat fermentum.
Nulla tincidunt leo ut lectus semper pellentesque.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Ut scelerisque velit ac porta tristique.
";
let substitution = "";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/