Les exemples sont les suivants:
public static String repdomain (String Source, String Domain, String Element, String atr) {String img = ""; Modèle p_image; Matcher M_IMAGE; String regex_img = "<" + élément + "[^ <>] *? // s" + attr + "= ['/"]? (. *?) [' / "]? (// s. *?)?>"; p_image = motive.compile (regex_img, pattern.case_insensitive); m_image = p_image.matcher (source); while (m_image.find ()) {img = m_image.group (); Matcher m = motif.compile ("href // s * = // s * /"? (. *?) (/ "|> | // s +)"). Matcher (img); while (m.find ()) {String srcval = M.Group (1); if (srcval.indexof ("/ @ locataire")> = 0) {int idx = srcval.indexof ("/ @ locataire"); StringBuffer temp = new StringBuffer (); String dstval = temp.APPEND (domaine) .append (srcval.substring (idx + 1)). ToString (); source = source.replace (srcval, dstval); }}} return source; }Ce qui précède est le contenu complet de l'expression régulière Java que l'éditeur vous apporte pour obtenir la valeur d'attribut spécifiée et remplacer la balise HTML spécifiée. J'espère que tout le monde pourra soutenir Wulin.com plus ~