Consider the following.
function cleanText($text) {
return preg_replace("/[^0-9\p{Latin}\p{Cyrillic}\.\-\_\s+]+/u","",$text);
}
$tmp = "intro_|_text Mary had a little lamb, we'll be right back 123456789 абвгдђежзијкл ,./'* αβγδε šđ";
echo cleanText($tmp);
Expected output is (as seen on both phpfiddle.org, and repl.it):
intro__text Mary had a little lamb well be right back 123456789 абвгдђежзијкл . šđ
However, Xampp with PHP 7.4.8, and this site return the following (the latter with every PHP 7.4.*):
aMaryhadalittlelambwellberightback123456789абнллклл.šđ
If \p{Latin}\p{Cyrillic} is removed, the spaces are kept. What would be the correct way of having both single spaces and the specific alphabets inside preg_replace?