I want to create a regular expression for all sorts of numbers i.e whole numbers (+ve and -ve) and decimal numbers (+ve and -ve) with or without commas.
For e.g the regular expression should cover following number formats.
111 1.11 1,111 1,111.01 1,111,111.01
+111 +1.11 +1,111 +1,111.01 +1,111,111.01
-111 -1.11 -1,111 -1,111.01 -1,111,111.01
I have created two regular expressions for handling my scenario.
"^(\\+|-)?[0-9]\\d*(\\.\\d+)?$" // handles whole numbers with decimals
"^(\\+|-)?[0-9]\\d*(\\,\\d+)*?$" // handles whole numbers with commas
Now, I want to merge these two regular expressions in order to address my requirements.
Can anyone help me?
Thanks in advance.