// 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)^(wsrep_provider_options(?!.*\bgcache.size\b).*)('$)").unwrap();
let string = "wsrep_provider_options='gmcast.segment=0; ist.recv_addr=tcp://db7; ist.recv_bind=tcp://0.0.0.0; socket.ssl_cert=/etc/mysql/wsrep/ssl/gmnode.pem; socket.ssl_key=/etc/mysql/wsrep/ssl/gmnode.key; socket.ssl_ca=/etc/mysql/wsrep/ssl/gmca.pem'
wsrep_provider_options='gmcast.segment=0; ist.recv_addr=tcp://db7; ist.recv_bind=tcp://0.0.0.0; socket.ssl_cert=/etc/mysql/wsrep/ssl/gmnode.pem; socket.ssl_key=/etc/mysql/wsrep/ssl/gmnode.key; socket.ssl_ca=/etc/mysql/wsrep/ssl/gmca.pem; gcache.size=4G'
wsrep_provider_options='gcache.size=4G; gmcast.segment=0; ist.recv_addr=tcp://db7; ist.recv_bind=tcp://0.0.0.0; socket.ssl_cert=/etc/mysql/wsrep/ssl/gmnode.pem; socket.ssl_key=/etc/mysql/wsrep/ssl/gmnode.key; socket.ssl_ca=/etc/mysql/wsrep/ssl/gmca.pem'";
let substitution = "\\1; gcache.size=4G\\2";
// 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/