src/main/java/com/cloudbees/jenkins/support/util/WordReplacer.java
private static void replaceWords(StringBuilder input, String[] words, String[] replaces, boolean ignoreCase) {
        if (input == null || input.length()==0 || words == null ||
                words.length == 0 || replaces == null || replaces.length == 0) {
            return;
        }

        // the same number of word to replace and replaces to use
        if (words.length != replaces.length) {
            throw new IllegalArgumentException(String.format("Words (%d) and replaces (%d) lengths should be equals", words.length, replaces.length));
        }

        for(int i = 0; i < words.length; i++) {
            replaceWord(input, words[i], replaces[i], ignoreCase);
        }
    }
// To avoid repeat this code above
To avoid repeat this code above
To avoid repeat this code above
private static void replaceWords(StringBuilder input, String[] words, String[] replaces, boolean ignoreCase) {
        if (input == null || input.length()==0 || words == null ||
                words.length == 0 || replaces == null || replaces.length == 0) {
            return;
        }
        if (words.length != replaces.length) {
            throw new IllegalArgumentException(String.format("Words (%d) and replaces (%d) lengths should be equals", words.length, replaces.length));
        }
        for(int i = 0; i < words.length; i++) {
            replaceWord(input, words[i], replaces[i], ignoreCase);
        }
    }
private static void replaceWords ( StringBuilder input , String [ ] words , String [ ] replaces , boolean ignoreCase ) { if ( input == null || input . length ( ) == 0 || words == null || words . length == 0 || replaces == null || replaces . length == 0 ) { return ; } if ( words . length != replaces . length ) { throw new IllegalArgumentException ( String . format ( "Words (%d) and replaces (%d) lengths should be equals" , words . length , replaces . length ) ) ; } for ( int i = 0 ; i < words . length ; i ++ ) { replaceWord ( input , words [ i ] , replaces [ i ] , ignoreCase ) ; } }
To avoid repeat this code above
To avoid repeat this code above
// the same number of word to replace and replaces to use