Asp.Net 隱藏手機號中間四位爲*方法

需求:15088881234 > 150****1234

方法1:

string phone = "15088881234";
string p1 = phone.Substring(0, 3) + "****" + phone.Substring(7, 4);

 

方法2:

string phone = "15088881234";
string p2= Regex.Replace(phone "(\\d{3})\\d{4}(\\d{4})", "$1****$2");

//兩種方法都可以,請隨意

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章