in reply to vallidating a regular expression

For all the answers given here, as far as I can see your script does exactly what you asked it to do:

a) Validate that it's a two digit number
b) The number is less than or equal to 10

If you're expecting results other than '10' then must look at what the contents of $totalNumber is coming into the script, or redefine your problem (to say allow single digits, leading zeros, decimal points, negative signs, etc).