Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个格式如下的字符串:
String str = "AA.BBB..CC.DDDD...EE....F.G..H";
我想用一个点分割这个字符串,并以此作为输出:
AA BBB .CC DDDD . EE .. F G .H
str.split("\\.")当然没有工作。
str.split("\\.")
这应该有效:
str.split("(?<!\\.)\\.|(?<=\\.\\.)\\.(?!\\.)")
在这两种情况下应该拆分字符串:
.