必需是数字 可以是小数 不能是0
可以在验证控件中有效的
找了几个都没用
帮帮我

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.IO;
    using System.Xml;namespace CSharpTest
    {
        class Program
        {
            static void Main(string[] args)
            {
               string str=@"12.001";           Regex re = new Regex(@"([1-9]|[1-9][0-9]*)\.\d*[1-9]\d*");
               Console.WriteLine(re.Match(str).Value);          
            }
              }
    }
      

  2.   

    ^([1-9]\d+(\.\d+[1-9])?)|(0.\d+[1-9])$
      

  3.   

    ^([1-9]\d+(\.\d+[1-9])?)|(0.\d+[1-9])$dfdf
    1254
    0
    0.25
    546
    12.2564匹配:
    1254
    0.25
    546
    12.2564
      

  4.   

    参考 
     也可少许修改 即可^[1-9]\d*$    //匹配正整数
    ^-[1-9]\d*$   //匹配负整数
    ^-?[1-9]\d*$   //匹配整数
    ^[1-9]\d*|0$  //匹配非负整数(正整数 + 0)
    ^-[1-9]\d*|0$   //匹配非正整数(负整数 + 0)
    ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$   //匹配正浮点数
    ^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$  //匹配负浮点数
    ^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$  //匹配浮点数
    ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$   //匹配非负浮点数(正浮点数 + 0)
    ^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$  //匹配非正浮点数(负浮点数 + 0)