Is there a way (regular expression?) to check if a string is composed only of Cyrillic alphanumeric characters?
I need to validate an input to be in range of the Cyrillic alphabet, plus numbers, dashes and spaces
\p{Cyrillic}
matches Cyrillic characters (you can use Arabic, Greek, etc. for other alphabets)
\d
matches numbers
\s
matches whitespace characters
\-
matches dashes
<?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 />";
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With