<?php
header('Content-type: text/html; charset=utf8'); '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'
);
'02',
'84951234567 позвать люсю',
'849512345',
'849512345678',
'8 (409) 123-123-123',
'7900123467',
'5005005001',
'8888-8888-88',
'84951a234567',
'8495123456a',
'+1 234 5678901',
'+8 234 5678901',
'7 234 5678901'
);
function checkRegExp($pattern, $examples){
$count = count($examples); for($i = 0; $i < $count; $i++){
echo "строка \"{$examples[$i]}\" подходит \n";
}else{
echo "строка \"{$examples[$i]}\" не подходит \n";
}
}
}
$exp1 = '/^\s?(\+\s?7|8)([-\s\(\)]{0,4}\d){10}\s?$/';
checkRegExp($exp1, $wright);
checkRegExp($exp1, $wrong);
PD9waHAKaGVhZGVyKCdDb250ZW50LXR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD11dGY4Jyk7CiR3cmlnaHQgPSBhcnJheSgKICAgICc4NDk1MTIzNDU2NycsCiAgICAnKzc0OTUxMjM0NTY3JywKICAgICc4LTQ5NS0xLTIzNC01NjcnLAogICAgJyA4ICg4MTIyKSA1Ni01Ni01NicsCiAgICAnOC05MTEtMTIzNDU2NycsCiAgICAnOCAoOTExKSAxMiAzNDUgNjcnLAogICAgJzgtOTExIDEyIDM0NSA2NycsCiAgICAnOCAoOTExKSAtIDEyMyAtIDQ1IC0gNjcnLAogICAgJysgNyA5OTkgMTIzIDQ1NjcnLAogICAgJzggKCA5OTkgKSAxMjM0NTY3JywKICAgICc4IDk5OSAxMjMgNDU2NycKKTsKJHdyb25nID0gYXJyYXkoCiAgICAnMDInLAogICAgJzg0OTUxMjM0NTY3INC/0L7Qt9Cy0LDRgtGMINC70Y7RgdGOJywKICAgICc4NDk1MTIzNDUnLAogICAgJzg0OTUxMjM0NTY3OCcsCiAgICAnOCAoNDA5KSA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