La función principal es: reemplazar el valor de la etiqueta IMG SRC en la cadena HTML.
El código es el siguiente:
package com.junlenet.common.util;import java.util.regex.Matcher;import java.util.regex.Pattern;/** * html processing tool class* @author huweijun * @date July 13, 2016 at 7:25:09 pm */public class HtmlUtils {/** * Replace the attributes and values of the specified tag* @param str String to be processed* @param tagTag Name* @param tagAttrib The tag attribute value to be replaced* @param startTag New tag start tag* @param endTag New tag end tag* @return * @author huweijun * @date July 13, 2016 at 7:15:32 pm */public static String replaceHtmlTag(String str, String tag, String tagAttrib, String startTag, string endtag) {String regXpfFFortAg = "<// s*" + tag + "// s + ([^>]*) // s*"; string regxpfortagatTrib = tagattrib + "= // s*/" ([^/"] +)/"; patrón de patrónFortAg = patrones.compile (regxpfortag (RegXpFortagattrib, Pattern.case_insensitive); PatternForAttrib.Matcher (MatcherFortAg.Group (1)); MatcherFortAg.AppendReplacation (sb, sbreplace.ToString ()); class =/"imgbox/"> <li> <img id =/"160424/" src =/"uploads/allimg/160424/1-160424120t1-50.jpg/" class =/"src_class/"> </li> "); Content.append (" <li> <img id =/"150628/" src=/"uploads/allimg/150628/1-15062Q12247.jpg/" class=/"src_class/"></li></ul>"); System.out.println("The original string is:"+content.toString()); String newStr = replaceHtmlTag(content.toString(), "img", "src", "src =/" http://junlenet.com/ ","/"");El método anterior para reemplazar el valor SRC en la etiqueta IG en el script regular de Java es todo el contenido que he compartido con usted. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.