Reputation: 483
I have one regex to check if the 6 last numbers of a variable are not the same. I don't understand why my regex is not working ?
If $tel = "0601244567" it's ok but if $tel = "0601555555" or anything with the last 6 characters it's not working.
if (!preg_match("/^0[1-79][0-9]{2}(?!(\d)\1{5}$)\d{6}$/i", $tel)) {
$errors[] = array(
"tel" => "Wrong phone number."
);
}
Thanks in advance
Upvotes: 2
Views: 69
Reputation: 785038
This regex should work:
^(?!.*?(\d)\1{5}$)0[1-79]\d{8}$
Upvotes: 2