// 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)(?:\G(?!\A)|jpeg\("(?=[^"]*"[^)]*600\)))[^\s"]*\K\s+"#).unwrap();
let string = "# CHART: Share of persons living at risk of poverty or social exclusion ====
df <- S3R0004_M3080242 %>%
mutate(LAIKOTARPIS=parse_date_time(LAIKOTARPIS, \"y\"))
jpeg(\"./figures/Share of persons living at risk of poverty or social exclusion.jpeg\", width = 9, height = 6, units = 'in', res = 600)
ggplot(data = df, aes(x=LAIKOTARPIS, y=obsValue)+";
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/