preg_match("#^'d+'.?'d*$#",$number);
// 1 - return 1
// 1.2 - return 1
// 2.25 - return 1
// 1. - return 1 - but this not full number(there is no fractional part)
// and should return 0
我对支票号码有问题1.
因为我得到了1
而不是0
.为了解决问题,我尝试使用preg_match("#^'d+'.?(?='d)'d*#",$number);
但它不起作用,在后一种情况下1
返回0
。
请告诉我为什么preg_match("#^'d+'.?(?='d)'d*#",$number);
返回0
号码1
以及如何解决它?
试试这个:
preg_match("#^'d+('.'d+)?$#",$number);