public String cleanupDwgString(String dwgString) {
        String cleanString = dwgString;
        StringBuilder sb = new StringBuilder();
        //Strip off start/stop underline/overstrike/strike throughs
        Matcher m = Pattern.compile(underlineStrikeThrough).matcher(cleanString);
        while (m.find()) {
            if (! m.group(1).endsWith("\\")) {
                m.appendReplacement(sb, "");
            }
        }
        m.appendTail(sb);
        cleanString = sb.toString();

        //Strip off semi-colon ended markers
        m = Pattern.compile(endMarks).matcher(cleanString);
        sb.setLength(0);
        while (m.find()) {
            if (! m.group(1).endsWith("\\")) {
                m.appendReplacement(sb, "");
            }
        }
        m.appendTail(sb);
        cleanString = sb.toString();

            //new line marker \\P replace with actual new line
        m = Pattern.compile(newLine).matcher(cleanString);
        sb.setLength(0);
        while (m.find()) {
            if (m.group(1).endsWith("P")) {
                m.appendReplacement(sb, "\n");
            }
        }
        m.appendTail(sb);
        cleanString = sb.toString();

            //stacking fractions
        m = Pattern.compile(stackFrac).matcher(cleanString);
        sb.setLength(0);
        while (m.find()) {
            if (m.group(1) == null) {
                m.appendReplacement(sb, m.group(2) + "/" + m.group(3));
            }
        }
        m.appendTail(sb);
        cleanString = sb.toString();

        //strip brackets around text, make sure they aren't escaped
        m = Pattern.compile(curlyBraces).matcher(cleanString);
        sb.setLength(0);
        while (m.find()) {
            if (m.group(1) == null) {
                m.appendReplacement(sb, "");
            }
        }
        m.appendTail(sb);
        cleanString = sb.toString();
            //now get rid of escape characters
        cleanString = cleanString.replaceAll(escapeChars, "");
        //now unescape backslash
        cleanString = cleanString.replaceAll("(\\\\\\\\)", "\\\\");
        return cleanString;
    }
DWGReadFormatRemover removes the formatting from the text from libredwg files so only
the raw text remains.
What needs to be cleaned has been found on the following websites:
<p>
<a href="https://www.cadforum.cz/en/text-formatting-codes-in-mtext-objects-tip8640">
https://www.cadforum.cz/en/text-formatting-codes-in-mtext-objects-tip8640</a>
<p>
<a href="https://adndevblog.typepad.com/autocad/2017/09/dissecting-mtext-format-codes.html">
https://adndevblog.typepad.com/autocad/2017/09/dissecting-mtext-format-codes.html</a>
<p>
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-cad-module/src/main/java/org/apache/tika/parser/dwg/DWGReadFormatRemover.java