/** * @param theText - <b>not null</b> * @param expressionToBeReplaced - <b>not null</b> * @param expressionToReplace - <b>not null</b> * @return - <b>not null</b> */ public static String replaceRegexWithRegex( final String theText, final String expressionToBeReplaced, final String expressionToReplace) { Preconditions.checkNotNull(theText); Preconditions.checkNotNull(expressionToBeReplaced); Preconditions.checkNotNull(expressionToReplace); final String string = RegexUtil.replaceRegexWithRegex(theText, expressionToBeReplaced, expressionToReplace, true); Preconditions.checkNotNull(string); return string; }
/** * @param theText - <b>not null</b> * @param expressionsToBeReplaced - <b>not null</b> * @param expressionToReplace - <b>not null</b> * @return - <b>not null</b> */ public static String replaceRegexWordsWithRegex( final String theText, final String[] expressionsToBeReplaced, final String expressionToReplace) { Preconditions.checkNotNull(theText); Preconditions.checkNotNull(expressionsToBeReplaced); Preconditions.checkNotNull(expressionToReplace); String string = null; for (final String expressionToBeReplaced : expressionsToBeReplaced) { string = RegexUtil.replaceRegexWordWithRegex(theText, expressionToBeReplaced, expressionToReplace); if (!string.equals(theText)) { break; } } Preconditions.checkNotNull(string); return string; }
/** * @param text - </b>not null</b> * @param word - </b>not null</b> * @return - </b>not null</b> */ public static String replaceRegexWordWithRegexFromTheEnd( final String theText, final String expressionToBeReplaced, final String expressionToReplace, final boolean caseSensitive) { Preconditions.checkNotNull(theText); Preconditions.checkNotNull(expressionToBeReplaced); Preconditions.checkNotNull(expressionToReplace); String textInternal = null; textInternal = theText; textInternal = RegexUtil.replaceRegexWithRegex( textInternal, "([ ;,:-]|\\A)" + expressionToBeReplaced.trim() + "\\Z", expressionToReplace, caseSensitive); textInternal = textInternal.trim(); Preconditions.checkNotNull(textInternal); return textInternal; }