Understanding old JAVA code

1

I have a code here in the company and I need to understand what it actually does. By the method's naming I found that it removed the non-standard UTF-8 characters or something, giving a parsed I saw that it does not do exactly anything in the string I pass. I need someone to explain to me what this code actually does or give me some hints about it so I can judge if I remove it or create something better.

public static String replaceUTF8(String text) {
    String[] REPLACES = {"a", "e", "i", "o", "u", "c"};
    Pattern[] PATTERNS = new Pattern[REPLACES.length];
    PATTERNS[0] = Pattern.compile("[?????]", Pattern.CASE_INSENSITIVE);
    PATTERNS[1] = Pattern.compile("[????]", Pattern.CASE_INSENSITIVE);
    PATTERNS[2] = Pattern.compile("[????]", Pattern.CASE_INSENSITIVE);
    PATTERNS[3] = Pattern.compile("[?????]", Pattern.CASE_INSENSITIVE);
    PATTERNS[4] = Pattern.compile("[????]", Pattern.CASE_INSENSITIVE);
    PATTERNS[5] = Pattern.compile("[?]", Pattern.CASE_INSENSITIVE);
    String result = text;
    for (int i = 0; i < PATTERNS.length; i++) {
        Matcher matcher = PATTERNS[i].matcher(result);
        result = matcher.replaceAll(REPLACES[i]);
    }
    return result;
}
  

It's an old code and it's used in several places on the system, I really need to understand why it exists and will not affect it if I remove or modify it.

    
asked by anonymous 08.11.2017 / 12:55

0 answers