expression
Regex::split: delimiters
Split a string at nonoverlapping delimiter matches. A repeated-delimiter pattern can treat a run as one separator. This example uses the external regex crate; see the staged Cargo manifest. Expected stdout (not executed): ["red", "blue", "green"] Common mistake: Using regex splitting as a general quoted CSV parser.
Formal Syntax & Structure
rust syntaxrust
re.split(text)Working Example
Example Snippetrust
fn main() { let re = regex::Regex::new(r"[,;]+\s*").unwrap(); let fields: Vec<_> = re.split("red, blue;; green").collect(); println!("{:?}", fields);}