Hi,
fn main() {
let s = "a.b\\.c.d";
println!("{:?}", s.split(".").collect::<Vec<_>>());
}
This outputs:
["a", "b\\", "c", "d"]
How do i get below output?
["a", "b.c", "d"]
Hi,
fn main() {
let s = "a.b\\.c.d";
println!("{:?}", s.split(".").collect::<Vec<_>>());
}
This outputs:
["a", "b\\", "c", "d"]
How do i get below output?
["a", "b.c", "d"]
You can check out the regex libraries recommended by BurntSushi on SO for the look-behind functionality: https://stackoverflow.com/a/37973864
I don't think you need lookbehind here, if you don't strictly use split.
Thanks @Koray, will check that post. But was hoping that regex would have support for this.
@birkenfeld - i dont have a need to strictly use split. What are the methods to achieve this output?
Something like repeated scanning for ^(|.*?[^\\])\., and shortening the haystack after each match.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.