求一正则 要求匹配 >= -50 and <=1000 范围内的float型数 谢谢

解决方案 »

  1.   

    bool bl = Regex.IsMatch(str,@"^((-50)|(1000)|(((-[0-4][0-9])|(-[0-9])|([0-9]{1,3}))((\.([0-9]+))?)))$");
      

  2.   

    ^([5-9]\d([.]\d+)?|[1-9]\d{2}([.]\d+)?|1000([.]0+)?)$
      

  3.   

    Try
    If Regex.IsMatch(str, "^([5-9]\d([.]\d+)?|[1-9]\d{2}([.]\d+)?|1000([.]0+)?)$") Then

    Else

    End If
    Catch ex As ArgumentException
    'Syntax error in the regular expression
    End Try
      

  4.   

    ^(-[0-4]?\d([.]\d+)?|\d{1,3}([.]\d+)?|1000([.]0+)?)$
    Try
    If Regex.IsMatch(str, "^(-[0-4]?\d([.]\d+)?|\d{1,3}([.]\d+)?|1000([.]0+)?)$") Then

    Else

    End If
    Catch ex As ArgumentException
    'Syntax error in the regular expression
    End Try