Livecycle RegExp - 小数问题

Livecycle RegExp - trouble with decimal

在 Livecycle 中,我正在验证输入的数字是 0 到 10 并且允许刻钟。在这个 post 的帮助下,我写了以下内容。

if (!xfa.event.newText.match(/^(([10]))$|^((([0-9]))$|^((([0-9]))\.?((25)|(50)|(5)|(75)|(0)|(00))))$/))
    {
        xfa.event.change = "";
    };

问题是不接受经期。我试过将 \. 括在括号中,但这也不起作用。该字段是一个没有特殊格式的文本字段和更改事件中的代码。

哎呀,这是一个令人费解的正则表达式。这样可以简化很多:

/^(?:10|[0-9](?:\.(?:[27]?5)?0*)?)$/

解释:

^             # Start of string
(?:           # Start of group:
 10           # Either match 10
|             # or
 [0-9]        # Match 0-9
 (?:          # optionally followed by this group:
  \.          # a dot
  (?:[27]?5)? # either 25, 75 or 5 (also optional)
  0*          # followed by optional zeroes
 )?           # As said before, make the group optional
)             # End of outer group
$             # End of string

测试一下live on regex101.com