Skip to content

Instantly share code, notes, and snippets.

@benjamintanweihao
Created February 26, 2018 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamintanweihao/9d31980378ee86d6733f3ca53e140691 to your computer and use it in GitHub Desktop.
Save benjamintanweihao/9d31980378ee86d6733f3ca53e140691 to your computer and use it in GitHub Desktop.
fn main() {
let s1 = "x=123, y = 345, rule = B21/S334";
let s2 = s1.replace(" ", "");
let s3 = s2.split(',').collect::<Vec<_>>();
let s4 = &s3[0..2];
let s5 = s4.iter()
.flat_map(|&x| x.split('=').collect::<Vec<_>>())
.collect::<Vec<_>>();
println!("x = {:?}", s5[1]);
println!("y = {:?}", s5[3]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment