I need a regex for a 5 digit integer number with 2 decimals.
These would be correct:
- 12345.12
- 09856.99
- 45123.00
These wouldn't:
- 123.12
- 12345.6
- 98652
I need a regex for a 5 digit integer number with 2 decimals.
These would be correct:
These wouldn't:
Use this regex it will work
var regex = /^\d{5}\.\d{2}$/;
var num = '23445.09';
console.log(regex.test(num)); // True
var num2 = '12345.6'
console.log(regex.test(num)); // False
This would be correct : /^\d{5}\.\d{2}$/
var value = 12345.12;
value.toString().match(/^\d{5}\.\d{2}$/); // ['12345.12']
var value = 98652;
value.toString().match(/^\d{5}\.\d{2}$/); // null