Hello community,
I want to find sub strings and return the indexes from long string. If the sub strings occur multiple times in the long string, find out all of the sub strings. Suggestions are welcome.
Thanks
fn main() {
let long_string = "aaa bbb ccc bbb bbb";
let sub_string = "bbb";
let len = long_string.len();
let mut index: usize = 0;
while index != len {
let i = long_string[index..].find(sub_string);
if let Some(i) = i {
index += i;
println!("{:?}", index);
index += 1;
} else {
break;
}
}
}