I'm trying to make validation number with format x or x.xx (4 or 4.21). The format I managed to use regex for the x (single digit) is \ b \ d \ b
.
For x.xx format (two decimal places) I haven't found the regex pattern yet
$tes = 1;
if(!preg_match('\b\d\b', $tes)){
echo 'right format';
}else{
echo 'not right';
}