<?php
/**
* 28.04.2015 (9:45)
* Shift.php
* PhpStorm
*/
header("Content-Type: text/plain; charset=utf-8");
// $sentence = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было. Но, все OK";
$sentence = "roses are red,and violets are blue.whatever you do i'll keep it for you.";
// $sentence = "привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.";
/* Делает первую букву в строке заглавной */
function makeFirstLetterUppercase($text)
{
$text = $firstLetter . $otherLetters;
return $text;
}
/* исправляет текст */
function fixText($text)
{
$result = '';
$regexp = '![.]!u';
$regexpRemoveSpace = '/(\s+[,!\.\?]|[,!\.\?][^\s])/u';
$parts = preg_split($regexp, $text, 0, PREG_SPLIT_NO_EMPTY
); foreach ($parts as $key => $sentence) {
$sentence = trim($sentence); $sentence = makeFirstLetterUppercase($sentence);
if ($key > 0) {
$result = $result . ". " . $sentence;
} else {
$result .= $sentence;
}
}
return $result . ".";
}
$result = fixText($sentence);
echo "{$result}\n";
PD9waHAKCi8qKgogKiAyOC4wNC4yMDE1ICg5OjQ1KQogKiBTaGlmdC5waHAKICogUGhwU3Rvcm0KICovCgplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKaGVhZGVyKCJDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9dXRmLTgiKTsKCi8vICRzZW50ZW5jZSA9ICLQvdGDINGH0YLQvi4gICAgICDQvdC1INGB0LzQvtGC0YDQtdC7INC10YnQtSBibGFjayBtZXNhLtGPINGB0L7QsdC40YDQsNC70YHRjyDRgdC60LDRh9Cw0YLRjCAgLNC90L4g0LLRgdC1INC60LDQui3RgtC+INC90LXQutC+0LPQtNCwINCx0YvQu9C+LiDQndC+LCDQstGB0LUgT0siOwokc2VudGVuY2UgPSAicm9zZXMgYXJlIHJlZCxhbmQgdmlvbGV0cyBhcmUgYmx1ZS53aGF0ZXZlciB5b3UgZG8gaSdsbCBrZWVwIGl0I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