I have a string formated like this:
String str = "AA.BBB..CC.DDDD...EE....F.G..H";
And I want to split this string by a dot with this as output:
AA
BBB
.CC
DDDD
.
EE
..
F
G
.H
str.split("\\.") of course did not work.
This should work:
str.split("(?<!\\.)\\.|(?<=\\.\\.)\\.(?!\\.)")
The string should be split in these 2 cases:
. is not preceded by another . . is not succeeded by ., and is preceded by 2 consecutive ..(?<=\\.\\.) in the 2nd part. :)
two dotsin between E and F, in sequence? Shouldn't be those on two separate lines?DDDD...EE....Fdoes not follow.