[6.0.0]
[删除获取中文拼音首字母]
This commit is contained in:
Binary file not shown.
@@ -1,7 +1,5 @@
|
|||||||
package com.mogo.och.common.module.utils;
|
package com.mogo.och.common.module.utils;
|
||||||
|
|
||||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: wangmingjun
|
* @author: wangmingjun
|
||||||
* @date: 2021/11/26
|
* @date: 2021/11/26
|
||||||
@@ -13,19 +11,6 @@ public class PinYinUtil {
|
|||||||
* @return 大写首字母缩写的字符串
|
* @return 大写首字母缩写的字符串
|
||||||
*/
|
*/
|
||||||
public static String getPinYinHeadChar(String str) {
|
public static String getPinYinHeadChar(String str) {
|
||||||
str = str.replaceAll("[\\p{P}‘’“”|+=¥$<>^~~]", "");
|
return str;
|
||||||
StringBuilder convert = new StringBuilder();
|
|
||||||
for (int j = 0; j < str.length(); j++) {
|
|
||||||
char word = str.charAt(j);
|
|
||||||
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
|
|
||||||
if (pinyinArray != null) {
|
|
||||||
convert.append(pinyinArray[0].charAt(0));
|
|
||||||
} else {
|
|
||||||
if (!"".equals(String.valueOf(word).trim())){
|
|
||||||
convert.append(word);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return convert.toString().trim().toUpperCase();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user