Answer the question
In order to leave comments, you need to log in
Regular expression does not work correctly
On the one hand, everything is eerily trite - you need to allow the user to enter the first and last name in different fields, the conditions are Latin or Cyrillic, dot, space.
a-z
does not skip the entire Cyrillic alphabet and the parameter i
also does not work with it, moreover, a-z does not represent the entire range of Cyrillic.
I did it tritely: /^([a-zA-Z \.\-]{1,20}|[абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ \.\-]{1,20})$/
Everything is cool, but there are situations when this bastard does not take what he needs, and specifically the name "Phoenician" - and eats it in parts, completely - no!
The only thing I do before checking is to process the received data with the function trim()
, but the situation does not change even if it is removed.
Help, brothers and sisters!
Answer the question
In order to leave comments, you need to log in
In PHP in UTF-8, you must use the u modifier Manual
excerpt:
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 has been checked since PHP 4.3.5.
The expression becomes /^([az \.\-]{1,20}|[a-yayo \.\-]{1,20})$/ui
Grenades, you have the wrong system. In .NET, the pattern works for "Phoenician", just checked. Most likely a bug in the code, some left character is missing somewhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question