3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vBase = [ 'properName' => function($value) { return (bool)preg_match('/^(\p{Uppercase_Letter}{1}[A-Za-z\p{Cyrillic}]+){1}([\-\s]{1}\p{Uppercase_Letter}[A-Za-z\p{Cyrillic}]+)*$/', $value); }, ]; $tests = [ 'Коломиец-Московская', 'Петр Могила', 'Nikita', 'Philipp Gopkalo', 'test 12', '12test', 'test12', 'alex' ]; foreach ($tests as $test) { print_r( [ 'value' => $test, 'isValidFormat' => (integer)$vBase['properName']($test), ] ); }

preferences:
44.77 ms | 402 KiB | 5 Q