// 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"(?mi)• (.+?)\s+- FF([A-F0-9]{2})([A-F0-9]{2})([A-F0-9]{2})").unwrap();
let string = " • White - FFe4e4e4
• Light Gray - FFa0a7a7
• Dark Gray - FF414141
• Black - FF181414
• Red - FF9e2b27
• Orange - FFea7e35
• Yellow - FFc2b51c
• Lime Green - FF39ba2e
• Green - FF364b18
• Light Blue - FF6387d2
• Cyan - FF267191
• Blue - FF253193
• Purple - FF7e34bf
• Magenta - FFbe49c9
• Pink - FFd98199
• Brown - FF56331c";
let substitution = "\"$1\": [0x$2, 0x$3, 0x$4],";
// 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/