Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 角度指令需要带两个小数的正则表达式_Regex_Angular - Fatal编程技术网

Regex 角度指令需要带两个小数的正则表达式

Regex 角度指令需要带两个小数的正则表达式,regex,angular,Regex,Angular,我尝试使用这个指令,但我不能为两个小数设置正则表达式 如何设置正则表达式,例如 34.21 | 32.4 | 32 | 67. | 77 ^[0-9]+(\.[0-9]{0,2})?$ 测试用例: 1234 *matches* 12.23 *matches* 4343.2 *matches* 12123. *matches* .12 *does not match* 1.234 *does not match* 谢谢你的回答。但是你的正则表达式不起作用。请检查示例:我

我尝试使用这个指令,但我不能为两个小数设置正则表达式

如何设置正则表达式,例如 34.21 | 32.4 | 32 | 67. | 77

^[0-9]+(\.[0-9]{0,2})?$
测试用例:

1234   *matches*
12.23   *matches*
4343.2   *matches*
12123.   *matches*
.12   *does not match*
1.234   *does not match*

谢谢你的回答。但是你的正则表达式不起作用。请检查示例:我认为regex必须允许数字末尾带有点,比如45。5678.12123. 不匹配-必须是matched@VasiliyMazhekin你刚才在问题中没有提到这一点。我现在编辑了。也许吧