package com.fishercoder.solutions;

/**
 * 1108. Defanging an IP Address
 *
 * Given a valid (IPv4) IP address, return a defanged version of that IP address.
 * A defanged IP address replaces every period "." with "[.]".
 *
 * Example 1:
 * Input: address = "1.1.1.1"
 * Output: "1[.]1[.]1[.]1"
 *
 * Example 2:
 * Input: address = "255.100.50.0"
 * Output: "255[.]100[.]50[.]0"
 *
 * Constraints:
 * The given address is a valid IPv4 address.
 * */
public class _1108 {
    public static class Solution1 {
        public String defangIPaddr(String address) {
            //String.replaceAll() takes in a regex which needs to be escaped
            return address.replaceAll("\\.", "\\[\\.\\]");
        }
    }

    public static class Solution2 {
        public String defangIPaddr(String address) {
            //String.replace() takes in a string which does NOT need to be escaped
            return address.replace(".", "[.]");
        }
    }
}

@@ -33,422 +33,8 @@
 s;%0A%0A
-/**%0A * 1108. Defanging an IP Address%0A *%0A * Given a valid (IPv4) IP address, return a defanged version of that IP address.%0A * A defanged IP address replaces every period %22.%22 with %22%5B.%5D%22.%0A *%0A * Example 1:%0A * Input: address = %221.1.1.1%22%0A * Output: %221%5B.%5D1%5B.%5D1%5B.%5D1%22%0A *%0A * Example 2:%0A * Input: address = %22255.100.50.0%22%0A * Output: %22255%5B.%5D100%5B.%5D50%5B.%5D0%22%0A *%0A * Constraints:%0A * The given address is a valid IPv4 address.%0A * */%0A
 publ

refactor 1108