<?php
$text1 = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было." ;
// Для тестов
$text2 = "roses are red,and violets are blue.whatever you do i'll keep it for you." ;
$text3 = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.' ;
/* Делает первую букву в строке заглавной */
function makeFirstLetterUppercase( $text ) {
function ( $matches ) {
$replacement = $matches [ 1 ] . $firstLetter ;
return $replacement ;
} ,
$text ) ;
return $text ;
}
function fixSpaces( $text ) {
$text = preg_replace ( '/([а-яёa-z]+)\\s*([.,;:!?])\\s*([а-яёa-z]+)/ui' , '$1$2 $3' , $text ) ; return $text ;
}
/* исправляет текст */
function fixText( $text ) {
$fixedText = fixSpaces( $text ) ;
$fixedText = makeFirstLetterUppercase( $fixedText ) ;
return $fixedText ;
}
$results [ ] = fixText( $text1 ) ;
$results [ ] = fixText( $text2 ) ;
$results [ ] = fixText( $text3 ) ;
foreach ( $results as $result ) {
echo "{$result} \n " ;
}
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKJHRleHQxID0gItC90YMg0YfRgtC+LiAgICAgINC90LUg0YHQvNC+0YLRgNC10Lsg0LXRidC1IGJsYWNrIG1lc2Eu0Y8g0YHQvtCx0LjRgNCw0LvRgdGPINGB0LrQsNGH0LDRgtGMICAs0L3QviDQstGB0LUg0LrQsNC6LdGC0L4g0L3QtdC60L7Qs9C00LAg0LHRi9C70L4uIjsKLy8g0JTQu9GPINGC0LXRgdGC0L7QsgokdGV4dDIgPSAicm9zZXMgYXJlIHJlZCxhbmQgdmlvbGV0cyBhcmUgYmx1ZS53aGF0ZXZlciB5b3UgZG8gaSdsbCBrZWVwIGl0IGZvciB5b3UuIjsKJHRleHQzID0gJ9C/0YDQuNCy0LXRgi7QtdGB0YLRjCAyINGE0YPQvdC60YbQuNC4LHByZWdfc3BsaXQg0LggZXhwbG9kZSAs0L3QtSDQv9C+0L3QuNC80LDRj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