我有这个字符串如何拆分 5-28 14:00 - 5-28 18:00 the60s(.corp)。我想用空格分割它,除非空格有数字或-在它们周围。
我想要的结果是:
1. how
2. to
3. split
4. 5-28 14:00 - 5-28 18:00
5. the60s(.corp)
谢谢。
以下是我的代码:
String str = "how do I split 5-28 14:00 - 5-28 18:00 the60s(.corp)";
str = str.replaceAll("\\s+(?!(?=-|\\d+))", "@");
首先我用 @ 替换右边的空格,然后用 @ 分割字符串。但它不起作用。