Java Code Examples for org.apache.commons.lang3.StringUtils.replaceEach()

The following are Jave code examples for showing how to use replaceEach() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: zkAdmin   File: RegexpUtils.java   View Source Code Vote up 5 votes
/**
 * 将使用简易匹配语法的关键字修改为标准正则表达式
 * 简易语法就是用*表示匹配任意数量字符,用?表示匹配0~1个字符,其他字符一律按照字面理解。 这是为了和Windows用户的习惯相吻合
 * @param key
 * @return
 */
public static String simpleMatchToRegexp(String key) {
    //将除了* ?之外的字符全部修改为正则表达式原义
    key=escapeRegChars(key,STAR_QUESTION);
    key=StringUtils.replaceEach(key, new String[]{"*","?","+"}, new String[]{".*",".?",".+"});
    return key;
}
 
Example 2
Project: golos4j   File: Util.java   View Source Code Vote up 5 votes
/**
 * Конвертировать заголовка в url строку
 * 
 * @param title:
 *            заголовок
 * @return: ссылка.
 * @throws BusinessException
 *             бизнес исключение
 */
private static String replace(String text) throws BusinessException {
	if (StringUtils.isBlank(text)) {
		throw new BusinessException("Unable conver title tp permlink");
	}
	String[] abcCyr = { "а", "б", "в", "г", "д", "е", "ё", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р",
			"с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", " ", ".", "!" };
	String[] abcLat = { "a", "b", "v", "g", "d", "e", "jo", "zh", "z", "i", "j", "k", "l", "m", "n", "o", "p", "r",
			"s", "t", "u", "f", "h", "ts", "ch", "sh", "sch", "b", "", "", "e", "ju", "ja", "-", "-", "-" };
	return StringUtils.replaceEach(text.toLowerCase(), abcCyr, abcLat);
}
 
Example 3
Project: zkAdmin   File: RegexpUtils.java   View Source Code Vote up 4 votes
public static String[] getSimpleMatchResult(String str,String key,boolean strict){
    key=escapeRegChars(key,STAR_QUESTION);
    key=StringUtils.replaceEach(key, new String[]{"*","?","+"}, new String[]{"(.*)","(.?)","(.+)"});
    return getMatcherResult(str, key, strict);
}