<?php
$text = "привет . есть 2 функции . ";
// Для тестов
// $text = 'roses are red,and violets are blue.whatever you do i'll keep it for you.';
// $text = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.';
$regexp = '/[.!?]/u';
$sentence = preg_split($regexp, $text, -1, PREG_SPLIT_NO_EMPTY
);
foreach ($sentence as $value){
$uppertext = $uppertext. $value. ". ";
};
$regexpArray = [
'/[ ]+([.,:;!?])/u' => '$1',
'/([.,:;!?])([а-яёa-z])/u' => '$1 $2'
];
foreach($regexpArray as $regKey => $regValue){
};
echo $uppertext;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKJHRleHQgPSAi0L/RgNC40LLQtdGCICAgIC4gICAgICAg0LXRgdGC0YwgMiDRhNGD0L3QutGG0LjQuCAgICAuICAiOwovLyDQlNC70Y8g0YLQtdGB0YLQvtCyCi8vICR0ZXh0ID0gJ3Jvc2VzIGFyZSByZWQsYW5kIHZpb2xldHMgYXJlIGJsdWUud2hhdGV2ZXIgeW91IGRvIGknbGwga2VlcCBpdCBmb3IgeW91Lic7Ci8vICR0ZXh0ID0gJ9C/0YDQuNCy0LXRgi7QtdGB0YLRjCAyINGE0YPQvdC60YbQuNC4LHByZWdfc3BsaXQg0LggZXhwbG9kZSAs0L3QtSDQv9C+0L3QuNC80LDRjizQsiDRh9C10Lwg0LzQtdC20LTRgyDQvdC40LzQuCDRgNCw0LfQvdC40YbQsC4nOwoKJHJlZ2V4cCA9ICcvWy4hP10vdSc7Cgokc2VudGVuY2UgPSBwcmVnX3NwbGl0KCRyZWdleHAsICR0ZXh0LCAtMSwgUFJFR19TUExJVF9OT19FTVBUWSk7Cgpmb3JlYWNoICgkc2VudGVuY2UgYXMgJHZhbHVlKXsKCSR2YWx1ZSA9IHRyaW0oJHZhbHVlKTsKCSR2YWx1ZSA9IG1iX3N0cnRvdXBwZXIobWJfc3Vic3RyKCR2YWx1ZSwgMC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