标签:
/// <summary> /// 字符串马赛克 /// </summary> /// <param name="source"></param> /// <param name="mask">马赛克</param> /// <param name="left">左边长度</param> /// <param name="length">打码长度</param> /// <returns></returns> public static string ToMask(this string source, char mask, int left, int length) { if (source.IsNullOrEmpty()) { return source; } var pattern = string.Format(@"(?<=^.{{{0}}}).{{{1}}}", left, length); return Regex.Replace(source, pattern, mask.Pad(length)); }
string类扩张 ,可运用于电话号码打* 号
标签:
原文地址:http://www.cnblogs.com/Linyb/p/4380111.html