Class WordReplacer
java.lang.Object
com.cloudbees.jenkins.support.util.WordReplacer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
replaceWord
(StringBuilder input, String word, String replace) Replace all occurrences of word by replace in the input.static String
replaceWord
(String input, String word, String replace) Replace all occurrences of word by replace in the input.static void
replaceWordIgnoreCase
(StringBuilder input, String word, String replace) static String
replaceWordIgnoreCase
(String input, String word, String replace) Replace all occurrences of word by replace in the input.static void
replaceWords
(StringBuilder input, String[] words, String[] replaces) static String
replaceWords
(String input, String[] words, String[] replaces) Replace all words in the input by the replaces.static String
Replace all matches in the input by their replacement.static String
Replace all matches in the input by their replacement.static void
replaceWordsIgnoreCase
(StringBuilder input, String[] words, String[] replaces) static String
replaceWordsIgnoreCase
(String input, String[] words, String[] replaces) Replace all words in the input by the replaces.
-
Constructor Details
-
WordReplacer
public WordReplacer()
-
-
Method Details
-
replaceWords
Replace all matches in the input by their replacement. Matcher#appendReplacement is used and therefore `\` and `$` characters must be escaped in the replacement string. NOTE: To ignore casing, Pattern must be case-insensitive or contain all possible cases. And replacements must either be a case-insensitive map or have lowercase keys.- Parameters:
input
- the text where the replacements take placepattern
- the patternreplacements
- the new words to use
-
replaceWords
Replace all matches in the input by their replacement. Matcher#appendReplacement is used and therefore `\` and `$` characters must be escaped in the replacement string. NOTE: To ignore casing, Pattern must be case-insensitive or contain all possible cases.- Parameters:
input
- the text where the replacements take placepattern
- the patternreplace
- the replace function. Accepts the matched word, and return the replacement
-
replaceWords
Replace all words in the input by the replaces. The replacements happens only if the texts to replace are not part of a greater word, that is, if the text is a whole word, separated by nonCharacter.isLetterOrDigit(char)
characters.- Parameters:
input
- the text where the replacements take placewords
- the words to look for and replacereplaces
- the new words to use
-
replaceWordsIgnoreCase
Replace all words in the input by the replaces. The replacements happens only if the texts to replace are not part of a greater word, that is, if the text is a whole word, separated by nonCharacter.isLetterOrDigit(char)
characters.- Parameters:
input
- the text where the replacements take placewords
- the words to look for and replacereplaces
- the new words to use
-
replaceWords
- Parameters:
input
- the text where the replacements take placewords
- the words to look for and replacereplaces
- the new words to use
-
replaceWordsIgnoreCase
- Parameters:
input
- the text where the replacements take placewords
- the words to look for and replacereplaces
- the new words to use
-
replaceWord
Replace all occurrences of word by replace in the input. The replacement happens only if the word to replace is separated from others words, that is, it's not part of a word. The implementation is that the previous and next characters of the word must be aCharacter.isLetterOrDigit(char)
char.- Parameters:
input
- text where the replacements take placeword
- the word to replacereplace
- the new text to use
-
replaceWordIgnoreCase
Replace all occurrences of word by replace in the input. The replacement happens only if the word to replace is separated from others words, that is, it's not part of a word. The implementation is that the previous and next characters of the word must be aCharacter.isLetterOrDigit(char)
char.- Parameters:
input
- text where the replacements take placeword
- the word to replacereplace
- the new text to use
-
replaceWord
Replace all occurrences of word by replace in the input. The replacement happens only if the word to replace is separated from others words, that is, it's not part of a word. The implementation is that the previous and next characters of the word must be aCharacter.isLetterOrDigit(char)
char.- Parameters:
input
- text where the replacements take placeword
- the word to replacereplace
- the new text to use
-
replaceWordIgnoreCase
-