My regular expression will not work with a single digital number
/^[0-9]{1,7}\.?[0-9]{1,2}$/
I need it to work with unsigned numbers:
1 (single digit numbers, without fractions) - currently it fails on them 1.0; 0.31 (floating point numbers)
The number before the fraction can be 1-7 digits; after the fraction 1-2 digits.
Thanks you!
You indicate that there should be 1-7 digits, then an optional decimal point, then another 1-2 digits. Try:
/^[0-9]{1,7}(?:\.[0-9]{1,2})?$/
Please note that this does not allow trailing decimal places (ie "1."). If you want to allow this, this should work:
/^[0-9]{1,7}(?:\.[0-9]{0,2})?$/
Make the decimal point and the numbers after it optional. eg.
/^[0-9]{1,7}(\.[0-9]{1,2})?$/
, 1 - 7 , 1 - 7 , , 1 2 , , , , .
Source: https://habr.com/ru/post/1757998/More articles:Constructor inheritance problem - delphiis couchdb good for this occasion? - couchdbUsing a basic jQuery selector and unique element identifier - jquerygetting the index of a clicked item in a list - androidUsing app.config in MBunit test - c #Facebook apps and animated Gif downloads - javascriptJavascript function containing jQuery ajax - Function returns undefined - functionIdentification of registry and file system changes - c ++failed to pass the Template function as a callback parameter - c ++How to store data in an array in a mysql function or procedure - mysqlAll Articles