I
I
IvanN7772016-04-18 14:35:22
PHP
IvanN777, 2016-04-18 14:35:22

Regular expressions PHP UTF8, changing the expression from preg_replace to mb_ereg_replace stops working, what's wrong?

A simple code is presented, in theory it should cut off short words, but it only handles English letters.

$input_text = 'sdfsdf dsfds dfd и ltp';
echo(preg_replace('/\b\w{1,3}\b/', "", $input_text));

Output: sdfsdf dsfds and
In the task, however, Russians will be used.
It was assumed by me that if you change it to functions from the MB package, then Russian letters will be processed.
However, it
mb_ereg_replace('/\b\w{1,3}\b/', "", $input_text);
throws an error.
Although, as needed, I gave it a regular expression.
In theory, the first parameter is a regular expression.
Which he does not recognize how to be.
I need exactly UTF8

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-04-18
@IvanN777

Russian letters are perfectly handled by pcre. u flag .
ideone.com/9vlGtS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question