A regular expression is not working properly


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
For one, all eerily banal — it is necessary to let the user enter name and surname in different fields, — the Latin or Cyrillic alphabets, dot, space.
a-z does not pass all the Cyrillic and the parameter i does not work with it, moreover — and I am not is a whole range of Cyrillic.

Made simple: /^([a-zA-Z \\.\\-]{1,20}|[абвгдеежзийклмнопрстуфхцчшщъыьэюяабвгдеежзийклмнопрстуфхцчшщъыьэюя \\.\\-]{1,20})$/
It's cool, but there are times when this bastard takes what is necessary, and specifically the name "Phoenician" — and in parts eats completely no!

The only thing that is done before the check — the resulting data is processed by the function trim(), but the situation does not change even if it is clean.

Help me out, brothers and sisters!
by | 7 views

5 Answers

0 like 0 dislike
PHP UTF-8, you must use the u modifier
\r
Excerpt from manual:
u (PCRE_UTF8)
This modifier turns on additional functionality of PCRE that is incompatible with Perl. Pattern strings are treated as UTF-8. This modifier is available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32. UTF-8 validity of the pattern is checked since PHP 4.3.5.
\r
The expression takes the form /^([a-z \\.\\-]{1,20}|[a-Yaya \\.\\-]{1,20})$/ui
by
0 like 0 dislike
Grenades, You do not have the system. In .NET pattern works for "Phoenician", just checked. Likely a bug in the code somewhere some left symbol gets.
by
0 like 0 dislike
Yes, and ^([a-zA-Z \\.\\-]{1,20}|[a-za-z \\.\\-]{1,20})$ works great.
by
0 like 0 dislike
>> абвгдеежзийклмнопрстуфхцчшщъыьэюяабвгдеежзийклмнопрстуфхцчшщъыьэюя
\r
use .Net and js...
....a-zA-Zа-ya-Yaya...
\r
I do not remember exactly about the "th" but it seems part of the range...
by
0 like 0 dislike
Point in the listing does not need to be escaped, and the hyphen at the end too (but only if it's at the end).
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
27,835 users