下面的代碼是否正確如果我打印了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