On a multilingual site, you need to check one field for the correctness of the entered data. The string must contain only letters. How to capture Russian, German, French, English and Spanish with a regular expression?
/^[^\W]+$/i – doesn’t work.
Answer 1, authority 100%
\pLwill match any letter: c, w, á
\pM*will match any number of modifiers – this is necessary because the letter á can be written as one character, and can be written as two: á.
I solved for many languages like this:
$lang = ‘abcgdeejzyklmn…heyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy arec are’
$lang = ‘abcde…ßABCDE…’;
preg_ match_all(‘/[a-zA-Z’.implode(”, $lang).’]/is’, $str, $out);
And this is the only scheme that worked with a bang, in all the others there were jambs with the understanding of any symbols of the language.
There are filters in php, dig in this direction, the article was on Habré.
In fact, these are regular expressions wrapped in functions. Most likely there is a filter for letters.
As far as I understand, the problem is solved. So just after.
/^[^W]+$/i – doesn’t work.
It doesn’t seem like it should. This is either a search for strings from non-W, or not from Wand \.
 must contain characters, ranges, or classes. I myself had nothing to do with php, but Google suggested:
POSIX Character Class Definitions