手机号中间四位替换

Posted li-lun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了手机号中间四位替换相关的知识,希望对你有一定的参考价值。

方法一 :根据未知替换

  String subStr = phone.Substring(3, 4);
  oldcellphone.Text = phone.Replace(subStr, "****");

方法二:正则表达式,

 

  Regex re = new Regex("(\d{3})(\d{4})(\d{4})", RegexOptions.None);
  var test= re.Replace("12345678901", "$1****$3");



以上是关于手机号中间四位替换的主要内容,如果未能解决你的问题,请参考以下文章