标签:ret 正则表达式 summary new code lan string star i++
C# 隐藏手机号码中间四位数字
if (!string.IsNullOrWhiteSpace(txtPhone.Text) &&
txtPhone.Text.Length == 11)
{
txtPhoneDesendent.Text = Regex.Replace(txtPhone.Text, "(\\d{3})\\d{4}(\\d{4})", "$1****$2");
}
字符串判断处理
/// <summary>
/// 手机号脱敏
/// </summary>
/// <param name="phoneNo"></param>
/// <returns></returns>
private string ConvertPhonedNo(string phoneNo)
{
if (string.IsNullOrEmpty(phoneNo))
return phoneNo;
if (phoneNo.Length < 11)
{
return phoneNo;
}
StringBuilder sb = new StringBuilder(phoneNo.Substring(0, 3));
for (int i = 0; i < phoneNo.Length - 5; i++)
{
sb.Append(‘*‘);
}
sb.Append(phoneNo.Substring(phoneNo.Length - 2));
return sb.ToString();
}
标签:ret 正则表达式 summary new code lan string star i++
原文地址:https://www.cnblogs.com/runningRain/p/13085718.html