QRegExp - Question on defining a regular expression
I am using QRegExp to validate user input. I would like the user to input a number from 0 to 255. (Eventually this will be used to validate input of an IP address like 192.168.0.123)
At this point, I have a working expression that allows the user to enter 1-3 digits, each in the range 0-9:
This works, but allows the user to enter values from 0 to 999. How best to restrict the input to 0 to 255?
If the first digit entered is greater than 2, then we can only allow one more digit.
If the first digit is equal to 2, then if the user enters a total of three digits, the second and third digits cannot exceed 5.
Any guidance is appreciated.