JSFiddle - React, Tailwind, and code Playground
JavaScript
function test(str, expected) {
var re = /^\$([5-9]\d{2}|[1-9]\d{3,})\.\d{2}$/;
var result = re.exec(str)!==null;
var pass = result===expected;
var passFailText = pass ? "PASS" : "FAIL";
var bgcolor = pass ? "green" : "red";
var color = result ? "#FFC" : "#FCC";
console.log( '%c' + passFailText + " : " + str + " : " + result, 'color: ' + color + ";background-color: " + bgcolor);
}
test("asdf", false);
test("$1.00", false);
test("$500", false);
test("$500.0", false);
test("500.00", false);
test("$500.00", true);
test("$1500.00", true);
test("$1000.00", true);
test("$0001.00", false);