主な関数は、HTML文字列のIMGタグSRCの値を置き換えることです。
コードは次のとおりです。
パッケージcom.junlenet.common.util; Import java.util.regex.matcher; Import java.util.regex.pattern;/*** HTML処理ツールクラス* @Author huweijun* @date 2016年7月13日7:25:09 PM*/public class htmlutils ot of of of of the of the of the of the of of of of of of of spectils htmlutils @param str string to processed* @param tagtag name* @param tagattrib @param starttag starttag starttag new tag start tag* @param endtag new tag end tag* @return* @author* @date 2016年7月13日7:15:32 pm*/public statis string string string string string string starttag、string endtag){string regxpfortag = "<// s*" + tag + "// s +([^>]*)// s*"; string regxpfortagattrib = tagattrib + "= // s*/"([^//"] +)/" "; pattern pattern.compile(pattern_insive) (regxpfortagattrib、pattern.case_insensive); matcher matcherfortag = patternfortag(str); stringbuffer sb = new stringbuffer(); boolean result = matcherfortag.find(); Patternforattrib.matcher(matcherfort.find()); Matcherfort.AppendReplacement(sb、sbreplace.tostring()); class =/"imgbox/"> <li> <img id =/"160424/" src =/"uploads/allimg/160424/1-160424120t1-50.jpg/" class =/"src_class/"> </li> "); src =/"uploads/allimg/150628/1-15062q12247.jpg/" class =/"src_class/"> </li> </ul> "); system.out.println("元の文字列は: "+content.tostring()); "src"、 "src =/" http://junlenet.com/ "、"/"");JavaレギュラースクリプトのIGタグでSRC値を置き換える上記の方法は、私があなたと共有したすべてのコンテンツです。参照を提供できることを願っています。wulin.comをもっとサポートできることを願っています。