M
M
Michael R.2020-05-18 18:00:43
PHP
Michael R., 2020-05-18 18:00:43

Strange result of the regular season, how to treat?

Greetings!

From the string you need to get all the words that are more than 3 characters long. I wrote a regular expression and displayed the result, and there questions, instead of some characters, and parts of words begin and end in strange places.

- Checked regular here https://regex101.com/r/MGYN0I/2
- File encoding utf-8.
- Checked the script on Windows and Linux.

What to do?

$string = "организация охраны 21 617";
preg_match_all("/[а-я]{4,}/i", $string, $keywords);
print_r($keywords);


Array
(
    [0] => Array
        (
            [0] => ганиза�
            [1] => ия
            [2] => ан�
        )

)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-05-18
@Mike_Ro

Add modifier u:

preg_match_all("/[а-я]{4,}/ui", $string, $keywords);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question