zoukankan      html  css  js  c++  java
  • C#隐私字符替换

    class Program
        {
            static void Main(string[] args)
            {
    
                string str = ReplaceWithSpecialChar("221282188801019662", 4, 4);
                Console.WriteLine(str);
                Console.ReadKey();
            }
    
            /// <summary>
            /// 将传入的字符串中间部分字符替换成特殊字符
            /// </summary>
            /// <param name="value">需要替换的字符串</param>
            /// <param name="startLen">前保留长度</param>
            /// <param name="endLen">尾保留长度</param>
            /// <param name="replaceChar">特殊字符</param>
            /// <returns>被特殊字符替换的字符串</returns>
            private static string ReplaceWithSpecialChar(string value, int startLen = 4, int endLen = 4, char specialChar = '*')
            {
                try
                {
                    int lenth = value.Length - startLen - endLen;
                    string replaceStr = value.Substring(startLen, lenth);
                    string specialStr = string.Empty;
                    for (int i = 0; i < replaceStr.Length; i++)
                    {
                        specialStr += specialChar;
                    }
                    value = value.Replace(replaceStr, specialStr);
                }
                catch (Exception)
                {
                    throw;
                }
                return value;
            }
        }
  • 相关阅读:
    Sqli-Labs less46-53
    Sqli-Labs less38-45
    Sqli-Labs less32-37
    移动web问题小结
    伪类与伪元素
    HTML5 视频直播
    判断鼠标移入移出元素时的方向
    Input操作文件
    利用WebStorm来管理你的Github
    webkit开发,app移动前端知识点
  • 原文地址:https://www.cnblogs.com/qzxj/p/7140471.html
Copyright © 2011-2022 走看看