We have a PHP regex check as follows to check if the string contains any number having length greater than 6 to validate pincode entered within the address string.
$str = "1234567test";
$pattern = "~\d[- /\d]*\d{6}\b~";
if (preg_match_all($pattern, $str, $matches)) {
echo "Yes";
} else {
echo "no";
}
For the string 1234567 test
it is matching as expected but why it is failing for the string such as 1234567test
?