private String validatePortExposure(String input) throws IllegalArgumentException {
        try {
            Matcher matcher = Pattern.compile("(.*?)(?:/(tcp|udp))?$", Pattern.CASE_INSENSITIVE).matcher(input);
            // Matches always.  If there is a tcp/udp protocol, should end up in the second group
            // and get factored out.  If it's something invalid, it should get stuck to the first group.
            matcher.matches();
            Integer.valueOf(matcher.group(1));
            return input.toLowerCase();
        } catch (NumberFormatException exp) {
            throw new IllegalArgumentException("\nInvalid port mapping '" + input + "'\n" +
                    "Required format: '<hostIP>(/tcp|udp)'\n" +
                    "See the reference manual for more details");
        }
    }
Escape any slashes, quotes, and newlines int the value.  If any escaping occurred, quote the value.
@param key The key
@param value The value
@return Escaped and quoted key="value"
src/main/java/io/fabric8/maven/docker/assembly/DockerFileBuilder.java