1、把手机号中间4为隐藏
public string ReturnPhoneNO(string phoneNo) { Regex re = new Regex("(\d{3})(\d{4})(\d{4})", RegexOptions.None); phoneNo = re.Replace(phoneNo, "$1****$3"); return phoneNo; } //例: ReturnPhoneNO(131000084840); 输出:131****84840
2、手机号间隔显示
public string ReturnPhoneNO(string phoneNo) { Regex re = new Regex("(\d{3})(\d{4})(\d{4})", RegexOptions.None); phoneNo = re.Replace(phoneNo, "$1 $2 $3"); return phoneNo; } //例: ReturnPhoneNO(131000084840); 输出:131 0000 84840