【问题标题】:InputFormatter should allow negative and decimal numbersInputFormatter 应该允许负数和十进制数
【发布时间】:2021-09-07 09:07:32
【问题描述】:

我想让用户只添加数字,例如 123456.78912445, -12345.7777777899, 1234567, -12345678。 没有数量限制。 我如何为这个 textformfield 编写 Regrex 模式。 同样的问题inputFormatter should allow just decimal numbers and negative numbers

TextFormField(inputFormatters:[FilteringTextInputFormatter.allow(RegExp())])

【问题讨论】:

    标签: regex flutter dart inputformatter


    【解决方案1】:

    试试这个:^\-*\d+(?:.\d+)?$

    例如:https://regex101.com/r/yQDyoM/1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-27
      • 2012-09-05
      • 2019-04-22
      • 1970-01-01
      • 2022-11-29
      • 2013-04-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多