<?php
header("Content-Type: text/plain; charset=utf-8");
/**
* (\s?\+\s?7\s?|\s?8\s?) - +7 или 8 (с любым кол-вом пробелов между ними)
* (\s*\(*-*\s*\d\s*-*\)*\s*){10} - Пробел-Скобочка-Тире-Пробел-ЦИФРА-Пробел-Тире-Скобочка-Пробел
*/
$regexp = '!^(\s?\+\s?7\s?|\s?8\s?)(\s*\(*-*\s*\d\s*-*\)*\s*){10}$!';
'84951234567',
'+74951234567',
' +74957654321',
'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'
);
'02',
'84951234567 позвать люсю',
'849512345',
'849512345678',
'8 (409) 123-123-123',
'7900123467',
'5005005001',
'8888-8888-88',
'8888-8888-888888888888888888888888888888888888888888888888888888',
'84951a234567',
'8495123456a',
'+1 234 5678901',
'+8 234 5678901',
'7 234 5678901'
);
echo "TRUE\n\n";
foreach ($correctNumber as $number) {
echo "[+] \"{$number}\"\n";
} else {
echo "[-] \"{$number}\"\n";
}
}
echo "\nFALSE\n\n";
foreach ($wrongNumber as $number) {
echo "[+] \"{$number}\"\n";
} else {
echo "[-] \"{$number}\"\n";
}
}
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CmhlYWRlcigiQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PXV0Zi04Iik7CgovKioKICogKFxzP1wrXHM/N1xzP3xccz84XHM/KSAtICs3INC40LvQuCA4ICjRgSDQu9GO0LHRi9C8INC60L7Quy3QstC+0Lwg0L/RgNC+0LHQtdC70L7QsiDQvNC10LbQtNGDINC90LjQvNC4KQogKiAoXHMqXCgqLSpccypcZFxzKi0qXCkqXHMqKXsxMH0gLSDQn9GA0L7QsdC10Lst0KHQutC+0LHQvtGH0LrQsC3QotC40YDQtS3Qn9GA0L7QsdC10Lst0KbQmNCk0KDQkC3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