// 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)^\w{3} [ :[:digit:]]{11}[._[:alnum:]-]+ kernel:( [ *[[:digit:]]+.[[:digit:]]+])?").unwrap();
let string = "Aug 1 09:33:49 samsung4-ubuntu kernel: [ 0.045109] pinctrl core: initialized pinctrl subsystem
Aug 1 09:33:50 samsung4-ubuntu kernel: [ 0.172476] Bluetooth: Core ver 2.22";
let substitution = "^\\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ kernel:( [ *[[:digit:]]+.[[:digit:]]+])?";
// 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/