Solution 1
Simply use the grouping feature of the regex that is captured by parenthesis (). Get the matched group using Matcher.group() method.
Find all the occurrence between > and < and combine it as per your need.
Here is the regex pattern >([^\">].*?)<. Have a look at the demo on debuggex and regex101
Pattern description:
. Any character (may or may not match line terminators)
[^abc] Any character except a, b, or c (negation)
X*? X, zero or more times (Reluctant quantifiers)
(X) X, as a capturing group
Read more about
Sample code:
String string = "<a href=\"<a href=\"http://www.freeformatter.com/xml-formatter.html#ad-output\" target=\"_blank\">http://www.freeformatter.com/xml-formatter.html#ad-output</a>\">Links</a>";
Pattern p = Pattern.compile(">([^\">].*?)<");
Matcher m = p.matcher(string);
while (m.find()) {
System.out.println(m.group(1));
}
output:
http://www.freeformatter.com/xml-formatter.html#ad-output
Links
Solution 2
Try with String#replaceAll() method using (</a>)[^$]|([^^]<a(.*?)>) regex pattern.
Pattern says: Replace all the </a> that is not in the end and <a.*?> that is not in the beginning with the double quotes.
Find demo on regex101 and debuggex
Pictorial representation of this regex pattern:

Sample code:
String string = "<a href=\"<a href=\"http://www.freeformatter.com/xml-formatter.html#ad-output\" target=\"_blank\">http://www.freeformatter.com/xml-formatter.html#ad-output</a>\">Links</a>";
System.out.println(string.replaceAll("(</a>)[^$]|([^^]<a(.*?)>)", "\""));
output:
<a href="http://www.freeformatter.com/xml-formatter.html#ad-output">Links</a>