正则表达式

分割字符串

    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