Created
June 13, 2015 15:19
-
-
Save bfodeke/fa70775dce9a8861b525 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript price Regex | |
// Should work for the following prices. | |
var validPrices = ['90.99', '23', '231123.90', '90.00', '990,000.90', '$99.903', '$99,000.00']; | |
// Should fail for the following. | |
var invalidPrices = ['90,99', '993.999', '99,99.90']; | |
// Regex I have so far. | |
var priceRegex = /^\d+(\.\d{2})?$/; | |
validPrices.forEach( function (price) { | |
console.log(priceRegex.test(price)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment