public class Regex {
public static void main(String[] args) {
url();
}
static void url() {
String input = “黑马程序员 “;
Pattern pattern;
Matcher matcher;
pattern = Pattern.compile(“<a(?: [^>]*)+href=([^ >]*)(?: [^>]*)*>”);
matcher = pattern.matcher(input);
while (matcher.find()) {
System.out.println(matcher.group());
}
}
} |