The
instance is as follows:
public static string Repdomain (string source, string domain, string element, string attr
) {String img = "";
Pattern P_image;
Matcher M_image; String regex_img = "<" + element + "[^<>]*?\\s" + attr + "=[' \"]? (.*?) ['\"]? (\\s.*?)?
> ";
P_image = Pattern.compile (regex_img, pattern.case_insensitive);
M_image = P_image.matcher (source);
while (M_image.find ()) {img = M_image.group (); Matcher m = pattern.compile ("href\\s*=\\s*\"? *?)
(\ "|>|\\s+)"). Matcher (IMG);
while (M.find ()) {String srcval = M.group (1);
if (Srcval.indexof ("/@tenant") >=0) {int idx = Srcval.indexof ("/@tenant");
StringBuffer temp = new StringBuffer ();
String dstval = temp.append (domain). Append (srcval.substring (idx+1)). ToString ();
Source = Source.replace (Srcval, dstval);
}} return source; }
The above is the Java regular expression for everyone to get the specified value of the specified attribute of the HTML tag and replace the method all the content, I hope that we support cloud-Habitat Community ~