This covers all of your examples, allows for negatives, and applies a 9-digit decimal limit:
/^[+-]?(?=.?\d)\d*(\.\d{0,9})?$/
Demo Version: https://regexr.com/4chtk
To break this:
[+-]?
Since both sides of the decimal point are optional, (?=.?\d) ensures that at least one of them is present. Thus, a number can have an integer part, a decimal part, or both, but not both.
One thing that I want to point out is that this template allows 23. , which was in your example. Personally, I would call it the wrong number, but it's up to you. If you change your mind about this, it will become much easier ( demo ):
/^[+-]?\d*\.?\d{1,9}$/
source share