java
html
c
python
mysql
database
xcode
android
ruby-on-rails
visual-studio
eclipse
silverlight
html5
json
facebook
oracle
tsql
php5
asp
postgresql
As I said in the comments - your first non-zero digit will count, then you add two more - which will now allow three-digit numbers like 915. To solve this the regexp way (with your testcases):
915
^[+-]?(?:(?!0)\d{1,2}|0)(?:\.[05])?$
I use negative lookahead (?!0) to make sure the first digit is not a zero, then just require the desired number of digits. It also allows 0.5 and similar through the |0 disjunction. If you prefer .5, it'll be this:
(?!0)
0.5
|0
.5
^[+-]?(?!0)\d{,2}(?:\.[05])?$
If you want to disallow 3.0 (allowed by your rules) and only allow 3 (as you imply in the examples), replace the last part:
3.0
3
^[+-]?(?:(?!0)\d{1,2}|0)(?:\.5)?$
However, this is much less readable than @Arkku's nice Float(number); use regexps if you really need them.
Float(number)
How about Float(number) (catch exceptions to detect parse errors) and then verify the floating point number? This will be easier for several of the properties than writing a regex. If you need to force a subset of the syntax accepted by Ruby to be used (why?), check only that part with a regex.
Here's a whole webpage on validating floats in regular expressions: http://www.regular-expressions.info/floatingpoint.html
That said,
{1,1}
{1}
0.5xyz
$
With the above changes, it'd look like this: /^[-+]?[1-9]\d{0,2}(\.\d)?$/
/^[-+]?[1-9]\d{0,2}(\.\d)?$/