正则表达式匹配文本
<span class="fb">作者:<a
href="space.php?action=viewpro&uid=6202438"
target="_blank">xwzylpzb</a>
怎么写正则表达式,捕获xwzylpzb? 正则表达式
[解决办法]
public static void main(String[] args) {
String str="<a href="space.php?action=viewpro&uid=6202438" target="_blank">xwzylpzb</a>";
Pattern pattern=Pattern.compile("<a\\s+href=(?<url>.+?)>(?<content>.+?)</a>");
Matcher matcher = pattern.matcher(str);
while(matcher.find()){
System.out.println(matcher.group(2));
}
}