public static Pattern getPatternForFragment(String xmlFragment) {
        assert xmlFragment != null;

        StringBuilder patternString = new StringBuilder();
        String[] lines = xmlFragment.split("\n");
        for (int i = 0; i < lines.length; i++) {
            String line = lines[i];
            line = StringUtils.replace(line, "\"", "\\\"");
            line = StringUtils.replace(line, ".", "\\.");
            if (i == 0) {
                patternString.append("([ ]*)").append(line).append("\\n");
                continue;
            }
            patternString.append("[ ]*").append(line).append("\\n");
        }
        return Pattern.compile(patternString.toString());
    }
Returns a pattern for a xmlFragment which ignores leading indents.
The first group can be used to determine ident.

@param xmlFragment the fragment where the pattern should be build for
@return the created pattern
plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/migration/TestCasePatcher.java