public void fun() { String text = "开奖日期:2021年3月28日 兑奖截止日期:2021年5月26日"; Pattern p = Pattern.compile("(\\d{4})年(\\d{1,2})月(\\d{1,2})日"); Matcher m = p.matcher(text); while (m.find()) { System.out.println(m.group(0)); } }
public void fun() { String text = "开奖日期:2021年3月28日 兑奖截止日期:2021年5月26日"; Pattern p = Pattern.compile("(\\d{4})年(\\d{1,2})月(\\d{1,2})日"); Matcher m = p.matcher(text); while (m.find()) { System.out.println(m.group(0)); } }