【发布时间】:2021-03-04 23:20:19
【问题描述】:
我的问题是我无法将正确的RegExp 放在一起。
我的目标是在逗号前最多允许 3 位数字,并且仅当有小数时,逗号后才允许 1 位数字。对于这种行为,我必须使用哪个 RegExp 或正则表达式?
想要的允许结果:000.0、00.0、0.0、000、00、0
这是当前的代码,但问题是这里也可以放置 4 位数字而不带小数:
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d{1,3}\.?\d{0,1}')),
],
我已经浏览了这些,但它们不适合我:
Javascript Regex to allow only 2 digit numbers and 3 digit numbers as comma separated
Javascript regex to match only up to 11 digits, one comma, and 2 digits after it
Jquery allow only float 2 digit before and after dot
【问题讨论】: