// 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)(?=Table \d+\.)").unwrap();
let string = "4 BLABLA\\r\\n Table 1. Real GDP\\r\\n Percentage changes\\r\\n 2016 2017 \\r\\nArgentina -2.5 2.7\\r\\nAustralia 2.6 2.5\\r\\n BLABLA \\r\\n Table 2. Nominal GDP\\r\\n Percentage changes\\r\\n 2011 2012\\r\\nArgentina 31.1 21.1\\r\\nAustralia 7.7 3.3\\r\\n";
let substitution = "\\n\\n\\n";
// 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/