I am trying to create some regular expressions to test some textbox controls. I did some research and testing, but can't get it to work. Examples of what I'm trying to create regular expressions are as follows:
- Range 0-45, 0 decimal places
- Range 0-20, 2 decimal places
- Range 16-65, 0 decimal places
- Range 0-99, 2 decimal places
- Range 0-1500000, 0 decimal places
- Range 0-200, 1 decimal place.
For 1 and 5, respectively, I used
([0-9]|[0-9]\d|45)$
([0-9]|[0-9]\d|1500000)$
The first problem I came across is the age range 16-65 (inclusive), where I don't want decimals. After the message here ( Regular expression to allow numbers from -90.0 to +90.0 ) I thought I could use the logic and make it judge, but I can't!
The expression I received was:
(\d|([1-6][6-4]))|65
Can someone tell me where I misunderstand this! And any help with the other examples above would be greatly appreciated.
source
share