我正在尝试从 Freemarker 中的链接检索 href 值,如下所示:
<a href="http://www.example.com" class="some-class">Test</a>
最佳答案
我尝试使用模式进行检索。你可以尝试一下
String str = "<a href=\"http://www.example.com\" class=\"some-class\">Test</a>";
Pattern pattern = Pattern.compile("(href=\"(.*?)\")");
Matcher macther = pattern.matcher(str);
if(macther.find()){
System.out.println(macther.group(1).substring(5));
}
关于java - 第: How to retrieve "href" value from <a> link,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41100980/