import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(/sites\\b[^\\\"]*/SitePages/[^\\\"]+)\\.aspx\\b";
final String string = "<div class=\"ms-wikicontent ms-rtestate-field\" style=\"padding-right: 10px\"><div class=\"ExternalClass8E56354CC4314DBA861E187B689F3A2B\"><table id=\"layoutsTable\" style=\"width:100%\"><tbody><tr style=\"vertical-align:top\"><td style=\"width:100%\"><div class=\"ms-rte-layoutszone-outer\" style=\"width:100%\"><div class=\"ms-rte-layoutszone-inner\" role=\"textbox\" aria-haspopup=\"true\" aria-autocomplete=\"both\" aria-multiline=\"true\"><a id=\"0::Home|Home\" class=\"ms-wikilink\" href=\"/sites/Team/Project/SitePages/Home.aspx\">Home</a> - <a id=\"1::Jenkins|Jenkins\" class=\"ms-wikilink\" href=\"/sites/Team/Project/SitePages/Jenkins.aspx\">Jenkins</a><h1 class=\"ms-rteElement-H1\">Jenkins Integration with Deployment Tools</h1>";
final String subst = "$1.html";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html