private static Map<Pattern, String> readMetadataPatterns(Element metadataDef) {
        Map<Pattern, String> metadata = new HashMap<>();

        NodeList children = metadataDef.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node node = children.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element child = (Element) node;
                if (child.getTagName().equals(METADATA_MATCH_TAG)) {
                    String metadataKey = child.getAttribute(METADATA_KEY_ATTR);
                    Pattern pattern = Pattern.compile(getString(child));
                    metadata.put(pattern, metadataKey);
                }
            }
        }

        return metadata;
    }
Builds and Returns an ExternalParser, or null if a check
command was given that didn't match.
tika-core/src/main/java/org/apache/tika/parser/external/ExternalParsersConfigReader.java