在JS中工作的正则表达式不适用于PHP

This regexp:

/^admin$|^[А-Яа-я]{2,20}\s[А-Яа-я]{2,20}\s[А-Яа-я]{2,20}$/

should match this string:

Пупкин Василий Иванович

It does match in JS (tested in Firebug console) and doesn't in PHP, and I cannot understand why.

In JavaScript, strings are always UTF-8. In PHP, however, they are a sequence of bytes. In order to allow PHP's regex engine to handle UTF-8 strings, add the u modifier to the regex.

You can also simplify your regex by removing all the uppercase letter ranges and using the i modifier, however this may be locale-dependent so be sure to test it!

For more on modifiers, check the docs!

You might want to use:

\p{Cyrillic}

Read Unicode character properties for more information.