将字符串 the boy plays the good games 在the和good处分割String str = "the boy plays the good games "; str.split("regex"),不知道这个regex该怎么写我要的效果是[the,boy plays the,good,games]
看楼主的意思不仅要把the和good处分割而是想要把the这个和后面的单词分割开来啊。String str = "the boy plays the good games "; String[] strs=str.split("(?<=the)\\b+"); System.out.println(Arrays.toString(strs));
String replaceAll = str.replaceAll("(the) ","$1,");
System.out.println(replaceAll);
String s=str.replaceAll("\\s(?=boy)|\\s(?=good)|\\s(?=games)", ",");
String[] strs=str.split("(?<=the)\\b+");
System.out.println(Arrays.toString(strs));