From e81924b4c004ff097b02e60cbb7f28a4c50dd814 Mon Sep 17 00:00:00 2001 From: wupengfei <834520024@qq.com> Date: 星期五, 12 九月 2025 16:07:47 +0800 Subject: [PATCH] Merge branch 'master' of http://120.26.58.240:8888/r/flexJobMiniApp --- packages/utils/common.ts | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/utils/common.ts b/packages/utils/common.ts index c36c689..a420b99 100644 --- a/packages/utils/common.ts +++ b/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,20 @@ 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'); +}; + +export function filterCN(str: string) { + return str.replace(/[\u4e00-\u9fa5]/gi, ''); +} + +export function filterNotCN(str: string) { + return str.replace(/[^\u4e00-\u9fa5]/gi, ''); +} -- Gitblit v1.9.1