\p{Cyrillic} matches Cyrillic characters (you can use Arabic , Greek , etc. for other alphabets)
\d matches numbers
\s matches space characters
\- matches dash
<?php header('Content-Type: text/html; charset=utf-8'); $pattern = "/^[\p{Cyrillic}\d\s\-]+$/u"; $subjects = array(12, "ab", "", '--', '__'); foreach($subjects as $subject){ $match = (bool) preg_match($pattern, $subject); if($match) echo "$subject matches the testing pattern<br />"; else echo "$subject does not match the testing pattern<br />"; } ?>
source share