Could you help me with this regular Expression please, it is supposed to allow these numbers: 123.56, 1.26, 12.36 but it admits 12345.56 12345.26...so instead of allow only three numbers before the point it admits five numbers.
this is my regular expression, the validation is on VB.NET, could you help me to fix it please
Dim Vestatura As String = "^[0-9]{1,3}((.)[0-9]{1,2})?$"
Dim Evaluar As Regex = New Regex(Vestatura)
Dim match As Match = Evaluar.Match(txtCMS.Text)
You need to escape the dot in-order to match a literal dot character. Because an unescaped dot would match any character.
Dim Vestatura As String = "^[0-9]{1,3}(([.])[0-9]{1,2})?$"
or
Dim Vestatura As String = "^[0-9]{1,3}(\.[0-9]{1,2})?$"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments