M
M
MasterCopipaster2020-06-17 10:17:38
PHP
MasterCopipaster, 2020-06-17 10:17:38

Why is preg_replace not working correctly in php?

I use this regular expression to clean up Cyrillic: https://regex101.com/r/NQQXSN/1

Judging by the site, everything works OK, it finds what it needs.

I use in code:

$string = '157AF0_УЦЕНКА';
preg_replace('/[\x{0410}-\x{042F}]+.*[\x{0410}-\x{042F}]+/iu', '', $string);
dump($string); // output "157AF0_УЦЕНКА"

Finds and replaces absolutely nothing. wtf? Why is this happening? I don't understand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Edward, 2020-06-17
@MasterCopipaster

$string = preg_replace('/[\x{0410}-\x{042F}]+.*[\x{0410}-\x{042F}]+/iu', '', $string);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question