// 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",(?=\D)").unwrap();
let string = "rgb(243,231,231),rgba(12,0,0,0.48)
hsl(0,80%,70%),#bada55
hsl(0,80%,70%),#bada55
red,red 60%,blue
yellow,blue 20%,#0f0
blue,green 40%,red
red,orange,yellow,green,blue,indigo,violet
red,rgba(255,0,0,0)
red,rgb(255,0,0)
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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/