50,528
社区成员
发帖
与我相关
我的任务
分享
String str = "#*%*#123#*%*#456#*%*##*%*#";
String []arr = str.split("#\\*%\\*#",7); //字符串分割
int index = 0;
for (String s : arr) {
System.out.println(index + "---: " + s);
index++;
}
0---:
1---: 123
2---: 456
3---:
4---:String str = "#*%*#123#*%*#456#*%*##*%*#";
String []arr = str.split("(?=(#- %
- #
- ))"); //字符串分割
System.out.println(arr.length);
for (String s : arr) {
System.out.println(s);
System.out.println(s.replaceAll("# - %
- #", ""
- )); //字符串替换
}