I have one parameter in json data called "content" from which I want to get image urls and display that images in ImageView dynamically.
I have tried Pattern and Matcher classes and I am getting firstimage url correctly but could not able to make out logic for more than one image url.
content is as follows:
"content":"<p style=\"text-align: justify;\">Huawei India has expanded the reach and availability of their online-only Honor smartphone series.<img class=\"aligncenter size-full wp-image-14114\" src=\"http:\/\/imageurl.jpg\"\/><p style=\"text-align: justify;\">Huawei India, along with it, has also confirmed that Honor smartphones will get the Android 6.0 Marshmallow updates with other devices in the upcoming year in the month of February.<\/p><img class=\"aligncenter size-full wp-image-14115\" src=\"http:\/\/second Image url.png\" \/>\n<p style=\"text-align: justify;\">The new update is likely to get Huawei Honor users to be excited, if you are a Honor smartphone user do share your feelings in the comment box below.<\/p>\n"
I am getting first image url as follows:
String imgRegex = "<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>";
Pattern p = Pattern.compile(imgRegex);
Matcher m = p.matcher(posts.getExcerpt());
String src = "";
if (m.find()) {
src = m.group(1);
imgPost.setVisibility(View.VISIBLE);
Log.v("groupCount : ",""+m.groupCount());
//Toast.makeText(this,"pattern : "+src,Toast.LENGTH_LONG).show();
Picasso.with(this)
.load(""+src)
.error(R.drawable.ic_launcher)
.into(imgPost);
}
Any idea how to get all image urls using PatternMatcher class or anything else??