D
D
Dan Ryehood2014-06-19 15:08:34
Programming
Dan Ryehood, 2014-06-19 15:08:34

How to write a regular expression for multilingual text?

I can't find a solution at all.
Let's imagine that I have a multilingual site. And users have the right to enter their first and last name in their own language when registering. And how many languages, so many alphabets...
The conditions for a regular expression in words are: text characters, spaces and a hyphen.
How to implement in practice??
Isn't it possible for each language to write its own regular expression listing all characters in Unicode? And if this is the only way out - maybe there are already some libraries specifically for this, in which hardworking people have already hammered alphabets?
(I'm interested in PHP implementation)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
KEKSOV, 2014-06-19
@wbird

Have a look at XRegExp . One of his plugins understands unicode letters.
For PHP, they write here that preg_match with the /u parameter does a similar job

D
Denis Ineshin, 2014-06-19
@IonDen

In such a situation, do the opposite.
Do not check for a range of required characters, but check for prohibited characters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question