1
public void saveMenuContent(String mainContent) { String content =""; String regex = "http://[\\s\\S]*?/[0-9]+"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(mainContent); while(matcher.find()) { System.out.println(matcher.group()); } }这则加一个?表示最短匹配的,不加就匹配最长匹配的 原文链接:https://www.f2er.com/regex/362165.html