import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<([\\w\\-\\/]+)( +[\\w\\-]+(=(('[^']*')|(\"[^\"]*\")))?)* *>";
final String string = " </div><!-- SectionHeaderWrapper --><div id=\"SectionContent\"><h3 id=\"sAdministrativeDataSummary\" class=\"mDisabled\">Administrative data</h3><h3 id=\"sWorkersHazardViaInhalationRoute\">Workers - Hazard via inhalation route</h3><h4>Systemic effects</h4><h5>Long term exposure</h5><dl class=\"HorDL\"><dt>Hazard assessment conclusion:</dt><dd>no hazard identified</dd></dl></dl></dl></dl></dl></dl><h5>Acute/short term exposure</h5><dl class=\"HorDL\"><dt>Hazard assessment conclusion:</dt><dd>no hazard identified</dd></dl><h6>DNEL related information</h6></dl></dl></dl></dl></dl><h4>Local effects</h4><h5>Long term exposure</h5><dl class=\"HorDL\"><dt>Hazard assessment conclusion:</dt><dd>DNEL (Derived No Effect Level)\n"
+ "Value:</dt><dd><span class=\"UserEntry\">0.02</span> mg/m³\n"
+ "Most sensitive endpoint:</dt><dd>repeated dose toxicity</dd></dl><h6>DNEL related information</h6><dl class=\"HorDL\"><dt>DNEL derivation method:</dt><dd>other: <span class=\"UserEntry\">Biocidal Products Regulation guidance for Human Health Risk Assessment (Volume III, Part B, December 2013</span>";
final String subst = "\\n";
final Pattern pattern = Pattern.compile(regex);
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