<?php
$text = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было.";
// Для тестов
// $text = 'roses are red,and violets are blue.whatever you do i'll keep it for you.';
// $text = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.';
/* исправляет текст */
function fixText($text) {
$regexp = "/(\\s+)?(,|[.!?])(\\s+)?/u";
$temp = preg_split("//u", $temp, null, PREG_SPLIT_NO_EMPTY
); for ($i = 0; $i < (count($temp) - 2); $i++) { if (($temp[$i] == "." || $temp[$i] == "!" || $temp[$i] == "?") && ($temp[$i + 1] == " ")){
}
}
return $temp;
}
$result = fixText($text);
echo "{$result}\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKJHRleHQgPSAi0L3RgyDRh9GC0L4uICAgICAg0L3QtSDRgdC80L7RgtGA0LXQuyDQtdGJ0LUgYmxhY2sgbWVzYS7RjyDRgdC+0LHQuNGA0LDQu9GB0Y8g0YHQutCw0YfQsNGC0YwgICzQvdC+INCy0YHQtSDQutCw0Lot0YLQviDQvdC10LrQvtCz0LTQsCDQsdGL0LvQvi4iOwovLyDQlNC70Y8g0YLQtdGB0YLQvtCyCi8vICR0ZXh0ID0gJ3Jvc2VzIGFyZSByZWQsYW5kIHZpb2xldHMgYXJlIGJsdWUud2hhdGV2ZXIgeW91IGRvIGknbGwga2VlcCBpdCBmb3IgeW91Lic7Ci8vICR0ZXh0ID0gJ9C/0YDQuNCy0LXRgi7QtdGB0YLRjCAyINGE0YPQvdC60YbQuNC4LHByZWdfc3BsaXQg0LggZXhwbG9kZSAs0L3QtSDQv9C+0L3QuNC80LDRjizQsiDRh9C10Lwg0LzQtdC20LTRgyDQvdC40LzQuCDRgNCw0LfQvdC40YbQsC4nOwoKLyog0LjRgdC/0YDQsNCy0LvRj9C10YIg0YLQtdC60YHRgiAqLwpmdW5jdGlvbiBmaXhUZXh0KCR0ZXh0KSB7CgkkcmVnZXhw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