<?php
$vBase = [
'properName' => function($value) {
return (bool)preg_match('/^([A-ZА-Я]{1}[A-Za-zА-Яа-я]+){1}([\-\s]{1}[A-ZА-Я]{1}[A-Za-zА-Яа-я]+)*$/', $value);
},
];
$tests = [
'Коломиец-Московская',
'Петр Могила',
'Nikita',
'Philipp Gopkalo',
'test 12',
'12test',
'test12',
'alex'
];
foreach ($tests as $test) {
print_r(
[
'value' => $test,
'isValidFormat' => $vBase['properName']($test),
]
);
}
preferences:
26.9 ms | 402 KiB | 5 Q