<?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 makeFirstLetterUppercase($text) {
$regexp = "/[.!?]/u";
$text = preg_split($regexp, $text, 0, PREG_SPLIT_NO_EMPTY
); for ($i = 0; $i < $length; $i++) {
$text[$i] = trim($text[$i]); $text[$i] = $first . $last . ".";
}
}
/* исправляет текст */
function fixText($text) {
$text = preg_replace("/[\\s]+,|,[\\s]+|([,])/u", ", ", $text); return makeFirstLetterUppercase($text);
}
$result = fixText($text);
echo "{$result}\n";
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoJ3V0Zi04Jyk7CgokdGV4dCA9ICIg0L3RgyDRh9GC0L4uICAgICDQvdC1INGB0LzQvtGC0YDQtdC7INC10YnQtSBibGFjayBtZXNhLtGPINGB0L7QsdC40YDQsNC70YHRjyDRgdC60LDRh9Cw0YLRjCAgLCAgICAgINC90L4g0LLRgdC1INC60LDQui3RgtC+LCAgICAg0L3QtdC60L7Qs9C00LAg0LHRi9C70L4uIjsKLy8g0JTQu9GPINGC0LXRgdGC0L7QsgovLyR0ZXh0ID0gInJvc2VzIGFyZSByZWQsYW5kIHZpb2xldHMgYXJlIGJsdWUud2hhdGV2ZXIgeW91IGRvIGknbGwga2VlcCBpdCBmb3IgeW91LiI7Ci8vICR0ZXh0ID0gItC/0YDQuNCy0LXRgi7QtdGB0YLRjCAyINGE0YPQvdC60YbQuNC4LHByZWdfc3BsaXQg0LggZXhwbG9kZSAs0L3QtSDQv9C+0L3QuNC80LDRjizQsiDRh9C10Lwg0LzQtdC20LTRgyDQvdC40LzQuCDRgNCw0LfQvdC40YbQsC4iOwoKLyog0JTQtdC70LDQtdGCINC/0LXRgNCy0YPRjiDQsdGD0LrQstGDINCyIN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