【发布时间】:2016-12-21 11:00:08
【问题描述】:
我想匹配有或没有任何千位分隔符和/或小数的货币。
字符串示例
String part = "R4,491.25"; // must be able to match more ex : R12,550,000.60
我有什么
if( part.matches("\\R\\d*[.,\\s\\d*]+")){
System.out.println("C [" + part + "]");
}
找到这个Regex for number with decimals and thousand separator 和Python regex to match currency with or without comma or decimal
但两者都没有完成我所需要的。在 Javascrpt 中使用 regex101 我的例子似乎工作 https://regex101.com/r/rK2jMU/4
如何改进或更改我的正则表达式以满足上述要求?
提前致谢。
【问题讨论】:
-
你应该删除
R之前的转义反斜杠。 -
你能把它放在一个答案中,这样我就可以接受了。谢谢它的工作