正则表达式

分割字符串

    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

posted @ 2019-05-07 15:31  懒企鹅  阅读(125)  评论(0编辑  收藏  举报