So far I have simple "numbers" only ...
/^[0-9]+$/
How can it be done to not allow leading zero (not start with zero) or preg_replace that would remove all spaces and leading zero ? Thank You
So far I have simple "numbers" only ...
/^[0-9]+$/
How can it be done to not allow leading zero (not start with zero) or preg_replace that would remove all spaces and leading zero ? Thank You
Only numbers not starting with 0:
/^[1-9][0-9]+$/
Remove all leading spaces and zero:
$num = preg_replace('/^(?:0|\s)*([0-9]+)$/', '\1', ' 0999');
To remove all spaces in string, also those not leading, use str_replace. It can be done with regex, but if you are going to loop many numbers that would be slower.