c#通用代码
/// <summary> /// 替换手机号中间四位为* /// </summary> /// <param name="phoneNo"></param> /// <returns></returns> protected static string ReturnPhoneNO(string phoneNo) { Regex re = new Regex(@"(\d{3})(\d{4})(\d{4})", RegexOptions.None); phoneNo = re.Replace(phoneNo, "$1****$3"); return phoneNo; } /// <summary> /// 替换邮箱中间几位为*号 /// </summary> /// <param name="Email"></param> /// <returns></returns> protected static string ReturnEmail(string Email) { Regex re = new Regex(@"\w{3}(?=@\w+?.\S+)", RegexOptions.None); Email = re.Replace(Email, "****"); return Email; }