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

posted @ 2016-05-26 18:07  hllive  阅读(814)  评论(0编辑  收藏  举报