Could someone help me to generate a regular expression for checking if entered number is greater than 1. This is what I tried:'[1-9][0-9]|[2-9]' but this does not allow me to enter more than 2-digits. I very new into this.Please help me..
You can do that with the following regular expression: [2-9]|([1-9][0-9]+)
This means: a single digit between 2 and 9, or: a digit between 1 and 9 followed by one or more digits.
Regular expressions are very powerful, and sometimes people try to use them for everything. This is typically an example of where you don't really need a regular expression. Just checking if (n > 1)
is simpler and more clear than using a regular expression for this task.