【发布时间】:2015-04-22 08:50:43
【问题描述】:
private static final Pattern ptninhref =Pattern.compile(
"(?:.*\\<[aA][^\\>]*(?i)href(?-i)=\\\"[^\\\"]*)([^\\\"]*)");
public static List<String> captureValuesinhref(String largeText){
Matcher mtchinhref = ptninhref.matcher(largeText);
List<String> inHREF = new ArrayList<>();
while(mtchinhref.find()){
inHREF.add(mtchinhref.group());
如何只获取"link is given "?
当我使用(?:.*\<[aA][^\>]*(?i)href(?-i)=\"[^\"]*)([^\"]*)(?:[^\"]*\".*\</[aA]\>.*) 这个正则表达式代码时,它会给出如下输出:<a href="link is given here">link is given here</a>。
但仅需要输出:"link is given here"
我需要在 href 标签之外的链接。
有两个链接:
1 在 href 标记内。
2 在浏览器中显示的 href 标记之外。
我只需要第二个链接。
如何在netbeans中使用java来获取它?
【问题讨论】:
-
我没有完全理解这个问题,您介意详细说明一下吗?也许添加一些你到目前为止尝试过的代码。
-
你明白我想问什么了吗?
-
不,我不明白你的问题。
-
我想获取一个在 href 标记之外的 URL
-
w3schools.com">VisitW3Schools.com!
标签: java html netbeans web-scraping