I am trying to use preg_match to match numbers that start with a zero to indicate an invalid input. Numbers such as 01
, 0023
, 00.4
are invalid; however numbers such as 0.12
are valid. The input would be a calculator entry, such as 09 * 108 + 0.19 + 4009
. In this case, the expression would be invalid because of the 09
.
So far my expression looks like: preg_match("/[^1-9]+0[0-9]+/", $subject)
What I tried to do was match when a zero precedes any string of digits, but is also not preceded by another string of digits. So 109
is valid, but 1+09 is invalid. However it isn't working for cases like 1 + 4009
.