<?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) {
$text = $s . $text;
return $text;
}
/* исправляет текст */
function fixText($text) {
$regexp1 = "/([.!?]+)/ui";
$sentences = preg_split($regexp1, $text, 0, PREG_SPLIT_NO_EMPTY
|PREG_SPLIT_DELIM_CAPTURE);
foreach ($sentences as &$value) {
$value = makeFirstLetterUppercase($value);
}
$newtext = implode("", $sentences);
$regexp2 = "/(\\s*)([,;.!?]+)(\\s*)/ui";
return $result;
}
$result = fixText($text);
echo "{$result}\n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAokdGV4dCA9ICLQvdGDINGH0YLQvi4uLiAgICAgINC90LUg0YHQvNC+0YLRgNC10Lsg0LXRidC1IGJsYWNrIG1lc2Eu0Y8g0YHQvtCx0LjRgNCw0LvRgdGPINGB0LrQsNGH0LDRgtGMICAs0L3QviDQstGB0LUg0LrQsNC6LdGC0L4g0L3QtdC60L7Qs9C00LAg0LHRi9C70L4uIjsKLy8g0JTQu9GPINGC0LXRgdGC0L7QsgogLy8kdGV4dCA9ICJyb3NlcyBhcmUgcmVkLGFuZCB2aW9sZXRzIGFyZSBibHVlLndoYXRldmVyIHlvdSBkbyBpJ2xsIGtlZXAgaXQgZm9yIHlvdS4iOwovLyAkdGV4dCA9ICfQv9GA0LjQstC10YIu0LXRgdGC0YwgMiDRhNGD0L3QutGG0LjQuCxwcmVnX3NwbGl0INC4IGV4cGxvZGUgLNC90LUg0L/QvtC90LjQvNCw0Y4s0LIg0YfQtdC8INC80LXQttC00YMg0L3QuNC80Lgg0YDQsNC30L3QuNGG0LAuJzsKIAovKiDQlNC10LvQsNC10YIg0L/QtdG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