3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = "/^[a-zA-Z ,.\p{Han}]+$/u"; $tests = array( 'Mr Smith', 'Mr. Smith', 'Mr. 123 Smith', '姓名', 'tom!!!', 'Mary@', 'May#', 'john$', 'ee%', 'e^', 'EE&', 'EE(', 'vivek', '姓名#' ); foreach ($tests as $test) { if (preg_match($re, $test) !== 1) { echo $test . ' failed' . PHP_EOL; } }

preferences:
45.82 ms | 402 KiB | 5 Q