rust:字符串分割
fn main() {
let location = String::from("/sso.iam.local/auth/admin/realms/xxx/groups/c1bf8486-4c7c-4669-9939-ab765e5699e1");
let pos :Vec<&str> = location.split("/").collect();
println!("id: {}",pos[pos.len()-1]);
}
fn main() {
let location = String::from("/sso.iam.local/auth/admin/realms/xxx/groups/c1bf8486-4c7c-4669-9939-ab765e5699e1");
let pos = location.rfind("/").unwrap();
let (_, lst) = location.split_at(pos + 1);
println!("id:{}",lst);
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询