FED80. 判断是否符合 USD 格式
描述
给定字符串 str,检查其是否符合美元书写格式示例1
输入:
'$20,933,209.93'
输出:
true
HTML/CSS/JavaScript 解法, 执行用时: 880ms, 内存消耗: 77900KB, 提交时间: 2020-12-02
{"css":"","js":"function isUSD(str) {\n var reg=/^\\$\\d{1,3}(,\\d{3})*(\\.\\d{2})?$/;\n return reg.test(str);\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 880ms, 内存消耗: 77900KB, 提交时间: 2020-11-04
{"css":"","js":"function isUSD(str) {\n let reg = /^\\$\\d{1,3}(,\\d{3})*(\\.\\d{2})?$/;\n return reg.test(str);\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 882ms, 内存消耗: 77900KB, 提交时间: 2020-11-23
{"css":"","js":"function isUSD(str) {\n let reg = /^\\$([1-9]\\d{0,2}(,\\d{3})*)(\\.\\d{2})?$/g;\n return reg.test(str);\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 883ms, 内存消耗: 77860KB, 提交时间: 2020-11-21
{"css":"","js":"function isUSD(str) {\n return /^\\$[1-9]\\d{0,2}(,\\d{3})*(\\.\\d{2})?$/.test(str)\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 883ms, 内存消耗: 77900KB, 提交时间: 2020-12-25
{"css":"","js":"function isUSD(str) {\nreturn /^\\$\\d{1,3}(,\\d{3})*(\\.\\d{2})?$/.test(str);\n}","html":"","libs":[]}