第三步
查找html中对应条件字符串
Pattern pattern = Pattern.compile("href=/"(.+?)/"");
Matcher matcher = pattern.matcher("<a href=/"index.html/">主页</a>");
if(matcher.find())
System.out.println(matcher.group(1));//group(1)对应 (.+?)
}
eg2
Pattern pattern = Pattern.compile("<div id=/"content/" name='content'>(.+?)</div>");
Matcher matcher = pattern.matcher(asdf d<div id=/"content/" name='content'>什么呢,故事情节开始了<p> </div>dsfsdfsd );
if(matcher.find()){
System.out.println(matcher.group(1));}
打印结果: 什么呢,故事情节开始了<p>