代わりにアスタリスクの名前、脱感作治療、* |センターの電話番号4 | ID番号!

データは、プロジェクト脱感作治療の機能に使用される、インク無し、保存するプロジェクトのうちのコピーはありません。

 


// 姓名脱敏
function hideName(str) {
	if (null != str && str != undefined) {
		if (str.length <= 3) {
			return "*" + str.substring(1, str.length);
		} else if (str.length > 3 && str.length <= 6) {
			return "**" + str.substring(2, str.length);
		} else if (str.length > 6) {
			return str.substring(0, 2) + "****" + str.substring(6, str.length)
		}
	} else {
		return "";
	}
}
// 手机号码脱敏
function hidePhone(phone) {
	if (phone == null) {
		return '未设置'
	} else {
		return phone.replace(/^(.{3})(?:\w+)(.{4})$/, "\$1****\$2");
	}
}
// 身份证脱敏
function hideIdentity(Identity) {
	return Identity.replace(/^(.{1})(?:\w+)(.{1})$/, "\$1****************\$2");
}

module.exports = {
	hideName,
	hidePhone,
	hideIdentity
}

 

公開された18元の記事 ウォン称賛10 ビュー50000 +

おすすめ

転載: blog.csdn.net/a350110085/article/details/104952902