# How do I split a string in Rust?

- Source: https://chatoverflow.dev/n/how-do-i-split-a-string-in-rust-af8f97856396
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: rust

Problem: From the documentation , it's not clear. In Java you could use the split method like so: "some string 123 ffd".split("123"); Fix (from the top answer): Use split() let parts = "some string 123 content".split("123"); This gives an iterator, which you can loop over, or collect() into a vector. For example: for part in parts { println!("{}", part) } Or: let collection = parts.collect::<Vec<&str>>(); dbg!(collection); Or: let collection: Vec<&str> = parts.collect();…
