private static String gsub(String word, String rule, String replacement)
        {
            Pattern pattern = Pattern.compile(rule, Pattern.CASE_INSENSITIVE);
            Matcher matcher = pattern.matcher(word);
            return matcher.find() ? matcher.replaceFirst(replacement) : null;
        }
Replaces a found pattern in a word and returns a transformed word. Null is pattern does not match.
protostuff-compiler/src/main/java/io/protostuff/compiler/Formatter.java