[ACCEPTED]-regexp with russian lang-cyrillic

Accepted answer
Score: 19

Try a Unicode range:

'/[\x{0410}-\x{042F}]/u'  // matches a capital cyrillic letter in the range A to Ya

Don't forget the /u 4 flag for Unicode.

In your case:

"#\[name=([a-zA-Z0-9\x{0430}-\x{044F}\x{0410}-\x{042F} .-]+)*]#u"

Note that 3 the STAR in your regex is redundant. Everything 2 already gets "eaten" by the PLUS. This would 1 do the same:

"#\[name=([a-zA-Z0-9\x{0430}-\x{044F}\x{0410}-\x{042F} .-]+)]#u"
Score: 7

The common unicode script (supported since 7 pcre 3.3) provides a test for the property 6 Cyrillic.

e.g. replace all characters that are neither 5 cyrillic nor (latin) digits:

$string = '1a2b3cйdцeуfкбxюy';
echo preg_replace('/[^0-9\p{Cyrillic}]/u', '*', $string);

You can find 4 the documentation for that feature under 3 http://www.pcre.org/pcre.txt "Unicode character properties".
And 2 you have to specify the PCRE8 flag (u) as 1 described at http://docs.php.net/reference.pcre.pattern.modifiers

Score: 0

This one worked for me:

/^[а-яА-Я\p{Cyrillic}0-9\s\-]+$/ 

I have tested in 1 all the browsers including Safari

Score: 0

Among the most used alphabets in the internet.

This 2 works since a good while now, I believe 1 since php 5.6.

// Filter Chinese and Japanese HAN
if (preg_match("/\p{Han}+/u", " 余TEST杭丽人广播", $match)){echo "CHINESE, JAPANESE ";}
// Filter Cyrilic
if (preg_match("/\p{Cyrillic}/u", "Күңел радиосы ", $match)){echo "RUSSIAN ";}
// Filter Greek
if (preg_match("/\p{Greek}/u", "Πρακτορείο ", $match)){echo "GREEK ";}
// Filter Arabic
if (preg_match("/\p{Arabic}/u", "مشال راډیو", $match)){echo "ARABIC ";}
// Filter Armenian
if (preg_match("/\p{Armenian}/u", "Ազատություն ", $match)){echo "ARMENIAN ";}
// Filter Thai
if (preg_match("/\p{Thai}/u", "สวท.พะเยา", $match)){echo "THAI ";}
// Filter Georgian
if (preg_match("/\p{Georgian}/u", "რადიო თავისუფალი", $match)){echo "GEORGIAN";}

/* Output: */
/* CHINESE, JAPANESE RUSSIAN GREEK ARABIC ARMENIAN THAI GEORGIAN */

More Related questions