在我的php中,我使用preg_match来验证输入文本。用于货币值(例如5000或5000.00)的文本框或可以接受空白。preg_match only nummber,允许空格和货币格式
$pattrn="/^[0-9]{10}$/";
通过使用它可以验证数字只。 如何使用preg_match过滤此输入?
在我的php中,我使用preg_match来验证输入文本。用于货币值(例如5000或5000.00)的文本框或可以接受空白。preg_match only nummber,允许空格和货币格式
$pattrn="/^[0-9]{10}$/";
通过使用它可以验证数字只。 如何使用preg_match过滤此输入?
您可以使用:
$pattrn = "/^(?:\d+(?:\.\d+)?)?$/";
说明:
/^ # Assert position at the beginning of the string
(?: # Begin a non-capturing group
\d+ # Match one or more digits from 0-9
(?: # Begin a non-capturing group
\.\d+ # Match a dot (.) followed by one more digits from 0-9
)? # Make the capturing group optional
)? # Make the capturing group optional
$/ # Assert positon at the end of the string
你应该使用$ pattrn =“^((?:\ d \ d {3}。 ?| \ d {1,3})\ d {1,3},\ d {1,2})$“;
在这里看到的样品preg_match() or similar function for checking currency
可以接受; 6000.00,6000和空 –
检查了这一点http://stackoverflow.com/questions/10371476/preg-match-decimals-not-working –
尝试'$ pattrn =“/ ^(?:\ d +( ???:\ \ d +))$ /“'。 –
嗨,有陌生人@AmalMurali ;-) –