使用正则表达式 保留最近三个月的日期

public static void main(String[] args) {
String a = "2019-04-26,2019-05-26,2019-06-26,2019-07-28";
String b = a.replaceAll("(2019-04)\\S{3},", "");
System.out.println("替换前:" + a);
System.out.println("替换后:" + b);
}

  

截图:

猜你喜欢

转载自www.cnblogs.com/nongzihong/p/11413818.html
今日推荐