wwww4t

//IMG处理

publicstaticfinalStringIMG_FORMAT="<(img|IMG)[^>》]*?(src|SRC)=[\"\']([^>》]*?)[\"\'][^》]*?>";

bodyPattern=Pattern.compile(patternFormat.IMG_FORMAT);

bodyMatcher=bodyPattern.matcher(infoText);

while(bodyMatcher.find()){

intstartIndex=bodyMatcher.start();

intendIndex=bodyMatcher.end();

Stringurl=bodyMatcher.group(3);

if(url.startsWith("http:")){

url=url.replaceAll("&(amp;)*","&amp;");

infoText=infoText.replace(startIndex,endIndex,"<imgsrc=\""+url+"\"/》");

bodyMatcher=bodyPattern.matcher(infoText);

continue;

}

if(!urlFormat.checkProtocol(url)){

URLbaseURL=newURL(rootURL);

url=newURL(baseURL,url).toString();

url=url.replaceAll("&(amp;)*","&amp;");

infoText=infoText.replace(startIndex,endIndex,"<imgsrc=\""+url+"\"/》");

bodyMatcher=bodyPattern.matcher(infoText);

}else{

infoText=infoText.delete(startIndex,endIndex);

bodyMatcher=bodyPattern.matcher(infoText);

}

}

amp

相关推荐