using System.Linq;

namespace YBEE.EQM.Core;

public static class StringExtensions
{
    /// <summary>
    /// 清除空白字符
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static string ClearWhitespace(this string str)
    {
        if (str == null)
        {
            return null;
        }
        return string.Concat(str.Where(c => !char.IsWhiteSpace(c)));
    }
    /// <summary>
    /// 证件号码规范化处理
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static string IdNumberStdProcessing(this string str)
    {
        var nstr = ClearWhitespace(str) ?? "";
        nstr = nstr.Replace("（", ")").Replace("）", ")").Replace("－", "-").Replace("——", "-");
        return nstr.ToUpper();
    }
}
