I am trying to write an if statement in php with preg_match to say allow 4 numbers and then a dot and then 2 numbers…
This is what I have….
$string = "10000.000";
if (preg_match('[/^\d{0,4}(\.\d{1,2})?$/]', $string)){
return TRUE;
} else {
return FALSE;
}
is my preg_match code wrong?
This should work as you want it!
^start of string,[0-9]a number from 0 to 9,{4}4x times,\.a dot,$end of the string