I wrote PHP code to check the string with regular expression. Every string should start with white space and total length should be exactly 10.
$str = ' 123456789';
if(preg_match('/^([ 0-9]){10}+$/', $str)){
echo 'true';
}
echo 'false';
I have expected the following results when I change the $str
variable. But using the above regular expression, I only get the first one right.
$str = ' 1234567890'; //true
$str = '1234567890'; // false