有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    如果我理解你的意思,你可以使用一个(零或一个匹配项)正则表达式,比如-

    String in = "January 22, 2014";
    String[] arr = in.split(",?\\ ");
    for (String str : arr) {
        System.out.println(str);
    }
    

    输出为

    January
    22
    2014