Can anybody provide an algorithm that checks whether an input string is a decimal number in correct shape and form?
Rules of correct shape and form:
- At most two decimal places.
- For all practical purposes, the largest number is 99,999
Can anybody provide an algorithm that checks whether an input string is a decimal number in correct shape and form?
Rules of correct shape and form:
- At most two decimal places.
- For all practical purposes, the largest number is 99,999,999.99
- The integral part can use a space, or a comma, or a dot for a group separator.
- The decimal part can use a comma, or a dot for a separator.
Examples of correct shape and form:
1,234,567.89 // English style 1.234.567,89 // French style 1 234 567,89 // German style 1234567.89 // English mathematical style 1234567,89 // European mathematical style 12.00 12.0 12
Please, resist your temptation to propose Decimal.Parse or Decimal.TryParse. Either method merrily accepts strings such as “1,2,3,4”, which is not what I want.