wupengfei
96 分钟以前 7cf04da7eaba7cad9c3b5e5f674d2e038ebcd305
packages/utils/common.ts
@@ -53,6 +53,7 @@
 * @returns
 */
export function addStarForString(str: string, start = 0, end = 0) {
  if (!str) return '';
  return str.substring(0, start) + '*'.repeat(end - start) + str.substring(end);
}
@@ -129,3 +130,21 @@
export function filterJoin(list: any[], separator = '-') {
  return list.filter(Boolean).join(separator);
}
export const hiddenIDNumberForEnd6 = (realIDNumber: string) => {
  if (!realIDNumber) return '';
  return realIDNumber.replace(/^(\d+)(.{6})$/, '$1******');
};
export const hiddenPhone = (phone: string) => {
  if (!phone) return '';
  return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
};
export function filterCN(str: string) {
  return str.replace(/[\u4e00-\u9fa5]/gi, '');
}
export function filterNotCN(str: string) {
  return str.replace(/[^\u4e00-\u9fa5]/gi, '');
}