package unit; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Util { // 获取url路径的正则 private static final String URL_REG = "<a .* href=.*[^.exe.*]</a>"; /** * 正则表达式获取链接 * @return */ public String getHref(String str) { Pattern pattern = Pattern.compile(URL_REG); Matcher matcher = pattern.matcher(str); if (matcher.find()) return matcher.group(0); return null; } }
时间: 2024-10-10 08:01:41