下面的代码是否正确如果我打印了matcher.group(0),则发生错误。我是否以正确的方式打印值?Plz help.Logcat错误如下。将正则表达式的匹配器的值打印到logcat
String GetCddata=<p><a href="http://myimagefactorycollection.files.wordpress.com/2014/09/2db83fcf95c5fc036a00abfb412f50e4.jpg">
<img class="alignnone size-full wp-image-12" src="http://myimagefactorycollection.files.wordpress.com/2014/09/2db83fcf95c5fc036a00abfb412f50e4.jpg?w=529" alt="2db83fcf95c5fc036a00abfb412f50e4" />
</a><a href="https://myimagefactorycollection.files.wordpress.com/2014/09/0e397a47f88e18f8fb91d17db18c7edd-copy.jpg"><img class="alignnone size-full wp-image-4" src="http://myimagefactorycollection.files.wordpress.com/2014/09/0e397a47f88e18f8fb91d17db18c7edd-copy.jpg?w=529" alt="0e397a47f88e18f8fb91d17db18c7edd - Copy" />
</a></p><br /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/myimagefactorycollection.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/myimagefactorycollection.wordpress.com/3/" />
</a> <img alt="" border="0" src="http://pixel.wp.com/b.gif?host=myimagefactorycollection.wordpress.com&blog=75018866&post=3&subd=myimagefactorycollection&ref=&feed=1" width="1" height="1" />
]];
Pattern pattern = Pattern.compile("(?<=\\<a href=)(.*?)\\>");
Matcher matcher = pattern.matcher(GetCddata);
Log.v("dd",matcher.group(0));
http://i.stack.imgur.com/GKpOD.png
您得到一个错误:非法状态异常没有匹配成功,到目前为止 – 2014-09-19 08:08:55