更新时间:2023-02-20 08:10:52
我不是regex专家,但是可以使用 RegExr .
I'm no regex-guru, but was able to whip up the following with RegExr.
/(\$[0-9]+(\.[0-9]{2})?)/
匹配$35.03
和$35
.要接受$35,000.52
之类的格式,您需要包含,
Matches $35.03
and $35
. To accept formats like $35,000.52
you would need to include ,
/(\$[0-9,]+(\.[0-9]{2})?)/
这可能会有所改善,但是从我的初步测试来看,它工作得很好.
This could likely be improved upon, but from my preliminary tests, it works just fine.