Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Split string

  • split
fn main() {
    let text = "mouse cat cat   oliphant";
    println!("{text}");
    let parts = text.split(' ');
    // println!("{:?}", parts);
    for part in parts {
        println!("{}", part);
    }
}
mouse cat cat   oliphant
mouse
cat
cat


oliphant