V
V
voltd gand2019-03-23 17:31:42
PHP
voltd gand, 2019-03-23 17:31:42

Help with regular expressions. Why is Cyrillic not accepted?

if (preg_match_all("/(!пр)\s+(^[а-я])/i", $mess, $tok)) {

Here is the code, in the $mess variable, !pr k is stored, but for some reason it does not find it, such a problem is only with Russian letters.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Dart, 2019-03-23
@vladimir_volohov

Put a modifier u "/(!пр)\s+(^[а-я])/iu"
Video about modifiers

R
rPman, 2019-03-24
@rPman

It is necessary to work with non-Latin letters using the standard mbstring extension
php.net/manual/ru/book.mbstring.php see the mb_ereg_... methods by itself when specifying the correct encoding.
Also try regular expression modifier u (when using utf8)
php.net/manual/en/reference.pcre.pattern.modifiers.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question