C# 过滤地址字符串

89 阅读1分钟

C# 过滤地址字符串中的特殊符号,只保留汉字和数字

 //过滤地址字符串
        public static string FilterChar(string inputValue)
        {
            if (Regex.IsMatch(inputValue, "[A-Za-z0-9\u4e00-\u9fa5-]+"))
            {
                return Regex.Match(inputValue, "[A-Za-z0-9\u4e00-\u9fa5-]+").Value;
            }
            return "";
        }