使用java语言,正则表达式把下面的字符串中的href后面的的两个引号中间的三个字符串取出来
<ahref="/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twent...
<a href="/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:s&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCcQ2A4oAg">小尺寸</a>
</span>
<span class="gl">
-
<a href="/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:m&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCgQ2A4oAw">中尺寸</a>
</span>
<span class="gl">
-
<a href="/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:l&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCkQ2A4oBA">大尺寸</a>
</span>
</div>
</div> 展开
</span>
<span class="gl">
-
<a href="/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:m&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCgQ2A4oAw">中尺寸</a>
</span>
<span class="gl">
-
<a href="/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:l&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCkQ2A4oBA">大尺寸</a>
</span>
</div>
</div> 展开
1个回答
展开全部
public static void main(String[] args) throws ParseException {
String content = "<a href=\"/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:s&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCcQ2A4oAg\">小尺寸</a>" +
"</span><span class=\"gl\">- " +
"<a href=\"/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:m&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCgQ2A4oAw\">中尺寸</a>" +
"</span><span class=\"gl\">- " +
"<a href=\"/search?newwindow=1&safe=strict&hl=zh-CN&bih=777&biw=1231&q=boa+made+in+twenty&tbm=isch&tbs=simg:CAQSYRpfCxCo1NgEGgAMCxCwjKcIGjoKOAgBEhKjBaIFpAW5Ap8FW3ClBaYFxQIaIJhxZMoH2TYVhSkb9WeSmSHVaJC5dtfpifpPrJfTZqRZDAsQjq7-CBoKCggIARIEXjOHZQw,isz:l&sa=X&ei=-QXDUaCNJMmikwWa24DICA&ved=0CCkQ2A4oBA\">大尺寸</a></span></div></div>";
Pattern p = Pattern.compile("href=\"(.*?)\"");
Matcher m = p.matcher(content);
while(m.find()){
System.out.println(m.group(1));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询