I know this might be a novice question regarding Regex in general but I hope someone can help. I need a reg expression that accepts 0-3 digits numbers + zero or 1 occurence of the character “:” or “.” + 0-2 digit number. Also there should be no other characters allowed
The user can then input valid numbers like
100:, :0, :, 1, 10.6, 111:11
Thanks in advance.
You could use
The part
\d{0,3}matches zero to three digits, the part[:\.]\d{0,2}matches a:or., followed by up to two digits, the braces with the?make this part optional.^and$anchor the expression at the start and end of the string.See it in action at http://regexr.com?31tqd