asp.net常用字符串函数

/// <summary>
        /// 提取字符串中的数字
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string getNumber(string str)
        {
            return System.Text.RegularExpressions.Regex.Replace(str, @"[^d{2}-]*", "");
        }

  截取字符串:原字符:{Width=300, Height=200}

size = size.Replace("{Width=", "");//替换
size = size.Replace(" Height=", "");
size = size.Substring(0, size.Length - 1);//去掉最后一个

  截取之后:300,200

原文地址:https://www.cnblogs.com/hllive/p/5532163.html