private static final Pattern NAME_SEPARATOR = Pattern.compile("\\s*[,]+\\s*");
public static void main(String[] args) {
String[] names = NAME_SEPARATOR.split("hah , ahe ,h e");
Arrays.stream(names).forEach(System.out::println);
}
hah
ahe
h e
原文:https://www.cnblogs.com/lanqie/p/10825756.html