Please help me fix the error in this regular expression: /^src=/([^']+/i/'z)

For example, the link should be extracted from the following line:

 <img title='AB said his only regret was having to wage a court battle in his final months.' height='259' alt='assisted suicide' width='460' src='http://i.cbc.ca/1.2950084.1458319055!/fileImage/httpImage/image.jpg_gen/derivatives/16x9_460/assisted-suicide.jpg' /> <p>While more than 118 people have received a doctor-assisted death since the procedure became legal in Canada, that number likely represents only one tenth of those who made "serious requests" for medical help in dying, a Toronto physician says.</p> 

The picture may be of type .png. Sample source code:

 for (Item item : mRss.getChannel().getItem()) { String link = item.getDescription(); String PATTERN = "/^src=/([^']+/i/'z)"; Pattern p = Pattern.compile(PATTERN); Matcher m = p.matcher(link); link = link.substring(m.start(), m.end()); item.setLinkToImage(link); 

Thank you very much!

    1 answer 1

    try this:

     Pattern pattern = Pattern.compile(".+src='(.+)'"); Matcher matcher = pattern.matcher(str); if (matcher.find()) System.out.println(matcher.group(1));