本文整理匯總了Java中org.apache.commons.lang3.StringUtils.replaceEach方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.replaceEach方法的具體用法?Java StringUtils.replaceEach怎麽用?Java StringUtils.replaceEach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.replaceEach方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: simpleMatchToRegexp
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 將使用簡易匹配語法的關鍵字修改為標準正則表達式
* 簡易語法就是用*表示匹配任意數量字符,用?表示匹配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;
}
示例2: replace
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Конвертировать заголовка в 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);
}
示例3: getSimpleMatchResult
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
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);
}