☰
正则表达式-数据脱敏
2026/10/1 9:28:49 网站建设 项目流程
// 获取 * 字符串 var _getStartStr = function (startLen) { var startStr = ''; while (startLen > 0) { startStr += '*'; startLen--; } return startStr; } /** * 根据脱敏规则转换数据格式 * @param {*} type * @param {*} value * @returns */ var _tmByType = function (type, value) { var tmValue = ''; var valueLength = value.length; if (_getVals(value).length > 1) { return value; } if (!value || !type) return; switch (type) { case 'fixedMobile': var fixedTel = /^\d{3,4}-\d{7,8}$/.test(value) || /^\d{10,12}$/.test(value); var mobile = /^1[3456789]\d{9}$/.test(value); if (fixedTel) { tmValue = value.replace(/.(?=....)/g, '*'); } else if (mobile) { var startStr = _getStartStr(valueLength - 7); tmValue = value.replace(/^(.{3}).+(.{4})$/, '$1' + startStr + '$2');

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询