正则表达式提取数字

/// <summary>
  /// 获取字符串中的数字
  /// </summary>
  /// <param name="par"></param>
  /// <returns></returns>
  private int GetNumber(string par)
  {
   string strTempContent =par;
   strTempContent = System.Text.RegularExpressions.Regex.Replace(strTempContent, @"[^\d]*", "");
   return Convert.ToInt32(strTempContent);
  }
posted on 2006-11-03 20:12  感動常在  阅读(9708)  评论(2编辑  收藏  举报