Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一个正则表达式验证表达式来验证十进制值(x)是否如下:0.0<=x<=1.0
只允许保留一位小数。我该怎么做?
谢谢
试试这个,它将检查一位小数而不是其他建议的变体
^((0\.[0-9]{1})|(1\.0))$
正则表达式将是:
^(:?(:?0\.[0-9])|(:?1\.0))$
但是为什么不使用十进制比较呢?