wupengfei
2 天以前 45efb3621da6180d1caad28cb5e98d9afefbc21f
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);
}
@@ -130,5 +131,12 @@
  return list.filter(Boolean).join(separator);
}
export const hiddenIDNumberForEnd6 = (realIDNumber: string) =>
  realIDNumber.replace(/^(\d+)(.{6})$/, '$1******');
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');
};