<?php
$regexp = '/^([- \\)\\(]*)(\\+[- \\)\\(]*7|8)(([- \\)\\(]*)([0-9])([- \\)\\(]*)){10}$/ui';
'84951234567', '+74951234567', '8-495-1-234-567',
' 8 (8122) 56-56-56', '8-911-1234567', '8 (911) 12 345 67',
'8-911 12 345 67', '8 (911) - 123 - 45 - 67', '+ 7 999 123 4567',
'8 ( 999 ) 1234567', '8 999 123 4567', '8 4951234567'
);
$incorrectNumbers = array( '02', '84951234567 позвать люсю', '849512345', '849512345678',
'8 (409) 123-123-123', '7900123467', '5005005001', '8888-8888-88',
'84951a234567', '8495123456a',
'+1 234 5678901', /* неверный код страны */
'+8 234 5678901', /* либо 8 либо +7 */
'7 234 5678901' /* нет + */
);
validate($correctNumbers, $regexp);
validate($incorrectNumbers, $regexp);
function validate($numbers, $regexp){
foreach ($numbers as $number) {
echo "Номер {$number} корректен\n";
$regexp2 = '/[\\(\\) -]/ui';
$regexp3 = '/\\+7/ui';
echo "{$result}\n";
} else {
//echo "Номер {$number} некорректен\n";
}
}
}
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwogCiRyZWdleHAgPSAnL14oWy0gXFwpXFwoXSopKFxcK1stIFxcKVxcKF0qN3w4KSgoWy0gXFwpXFwoXSopKFswLTldKShbLSBcXClcXChdKikpezEwfSQvdWknOwoKIAokY29ycmVjdE51bWJlcnMgPSBhcnJheSggCiAgJzg0OTUxMjM0NTY3JywgICcrNzQ5NTEyMzQ1NjcnLCAnOC00OTUtMS0yMzQtNTY3JywgCiAgJyA4ICg4MTIyKSA1Ni01Ni01NicsICc4LTkxMS0xMjM0NTY3JywgJzggKDkxMSkgMTIgMzQ1IDY3JywgCiAgJzgtOTExIDEyIDM0NSA2NycsICc4ICg5MTEpIC0gMTIzIC0gNDUgLSA2NycsICcrIDcgOTk5IDEyMyA0NTY3JywgCiAgJzggKCA5OTkgKSAxMjM0NTY3JywgJzggOTk5IDEyMyA0NTY3JywgJzggNDk1MTIzNDU2NycKKTsKIAok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