I want user only input 0-9 and only once \".\"
patt = /[^0-9(.{1})]/
1.2222 -> true
1.2.2 -> false (only once \'.\')
help me , t
this is what you're looking for
$re = "~ #delimiter
^ # start of input
-? # minus, optional
[0-9]+ # at least one digit
( # begin group
\. # a dot
[0-9]+ # at least one digit
) # end of group
? # group is optional
$ # end of input
~xD";
this only accepts "123" or "123.456", not ".123" or "14e+15". If you need these forms as well, try is_numeric