0
Regular expression with number and dot only
I use ^[0-9]*$ regular expression for number only. It works fine but now I need regular expression for number and dot only like user enter 4000.92 etc. Please help.
5 Answers
+ 1
Hi Salman,
maybe ^[0-9]*\.[0-9]*$ or ^[0-9]+\.[0-9]*$ if you want to be sure that the result stats with a number and not with a dot.
Bye!
+ 1
Hi Salman,
I'm not sure what are you asking for. If you want only to accept the number.number format you could use ^[0-9]+\.[0-9]+$, but if you want to match with number.number o number (without decimals) formats you could use ^[0-9]+(\.[0-9]+)?$
0
Xavier, this works thank you. Just one more question these regular expression needs . (decimal) required like I cannot enter 45 it accept 45.0. How to make this dot optional means it accept 45 also 45.00 but not other except (0-9 and .)
Thank you.
0
Xavier Alonso, thank you. Its work with ^[0-9]+(\.[0-9]+)?$