, , . , , , , .
public static String[] excludeString(String whole, String token) {
whole = whole.replaceAll(token, token.replaceAll("\\s+", ""));
String[] strarr = whole.split("\\s+");
Collections.replaceAll(Arrays.asList(strarr), token.replaceAll("\\s+", ""), token);
return strarr;
}
:
public static void main(String[] args) {
String[] arr = excludeString("The city of San Francisco is truly beautiful!", "San Francisco");
System.out.println(Arrays.asList(arr));
}
, : "The city of San Francisco is truly beautiful!"
:
[The, city, of, San Francisco, is, truly, beautiful!]