Hi, how can i remove these specific chars in this String ?
To optain "Bob esponja" ?
Bob esponja [2016] - 090
I can´t remove:
2016 - 090
Hi, how can i remove these specific chars in this String ?
To optain "Bob esponja" ?
Bob esponja [2016] - 090
I can´t remove:
2016 - 090
Are you always trying to remove everything after the first '['
, plus any preceding whitespace? If so, here's one way:
if let Some(idx) = name.split('[').next().map(|s| str::trim_end().len()) {
name.truncate(idx);
}
Or if you want a new string instead of modifying the one you have, that'd be
let new_name = name
.split('[')
.next()
.map(str::trim)
.unwrap_or(&name)
.to_string();
Thank you so much.