| | |
| | | * @returns |
| | | */ |
| | | export function addStarForString(str: string, start = 0, end = 0) { |
| | | if (!str) return ''; |
| | | return str.substring(0, start) + '*'.repeat(end - start) + str.substring(end); |
| | | } |
| | | |
| | |
| | | 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, ''); |
| | | } |