<?php
function copyCase( $neededLetter , $symbol ) {
//if (ctype_upper($symbol)){ //почему-то не работает
}
return $neededLetter ;
}
$text = "ЗДЕЛАЛ СДЕСЬ КООРДИНАЛЬНО Привет,Жырный!труд:Шырокий?пассаЖЫР;зделаю Координально но, например СДЕСЬ сдесь решена проблема ушыбов.
ЗДЕЛАНО многое а? ведь эти ушы зделали мы. Один ананас но зато как ЗДЕЛАННЫЙ" ;
$simpleReplace = [ '/(к)оординально/ui' => '$1ардинально' , //кардинально
'/([,;!?:])([^,;!?:\\s]+)/u' => '$1 $2' , //пробелы после знаков препинани¤
'/([а-яЁ]+)\\s+((?:а|но)\\b)/ui' => '$1, $2' ] ; //знаки препинания
foreach ( $simpleReplace as $pattern => $replacement ) {
}
//здесь
function ( $matches ) {
$letter = copyCase( 'з' , $matches [ 1 ] ) ;
$word = "{$letter} {$matches[2]} " ;
return $word ;
} , $text ) ;
//зделал
function ( $matches ) {
$letter = copyCase( 'с' , $matches [ 1 ] ) ;
$word = "{$letter} {$matches[2]} {$matches[3]} " ;
return $word ;
} , $text ) ;
//жы-шы
function ( $matches ) {
$letter = copyCase( 'и' , $matches [ 2 ] ) ;
$word = "{$matches[1]} {$letter} {$matches[3]} " ;
return $word ;
} , $text ) ;
echo $text ;
?>
PD9waHAKICAgIHNldGxvY2FsZShMQ19BTEwsICdydV9SVScpOwogICAgZXJyb3JfcmVwb3J0aW5nKC0xKTsKICAgIG1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKICAgIGZ1bmN0aW9uIGNvcHlDYXNlKCRuZWVkZWRMZXR0ZXIsICRzeW1ib2wpewogICAgICAgIC8vaWYgKGN0eXBlX3VwcGVyKCRzeW1ib2wpKXsgLy/Qv9C+0YfQtdC80YMt0YLQviDQvdC1INGA0LDQsdC+0YLQsNC10YIKICAgICAgICBpZiAocHJlZ19tYXRjaCgnL1vQkC3Qr9CBXS91JywgJHN5bWJvbCkpewogICAgICAgICAgICByZXR1cm4gbWJfc3RydG91c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9yZWFjaCAoJHNpbXBsZVJlcGxhY2UgYXMgJHBhdHRlcm4gPT4gJHJlcGxhY2VtZW50KXsKICAgICAgICAkdGV4dCA9IHByZWdfcmVwbGFjZSgkcGF0dGVybiwgJHJlcGxhY2VtZW50LCAkdGV4dCk7CiAgICB9CgkvL9C30LTQtdGB0YwKICAgICR0ZXh0ID0gcHJlZ19yZXBsYWNlX2NhbGxiYWNrKCcvKNGBKSjQtNC10YHRjCkvdWknLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uKCRtYXRjaGVzKXsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbGV0dGVyID0gY29weUNhc2UoJ9C3JywgJG1hdGNoZXNbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICR3b3JkID0gInskbGV0dGVyfXskbWF0Y2hlc1syXX0iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkd29yZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sICR0ZXh0KTsKCS8v0LfQtNC10LvQsNC7CiAgICAkdGV4dCA9IHByZWdfcmVwbGFjZV9jYWxsYmFjaygnLyjQtyko0LTQtdC70LApKCg/OtGOfNC7fNC9KVxccyopL3VpJywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uKCRtYXRjaGVzKXsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbGV0dGVyID0gY29weUNhc2UoJ9GBJywgJG1hdGNoZXNbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICR3b3JkID0gInskbGV0dGVyfXskbWF0Y2hlc1syXX17JG1hdGNoZXNbM119IjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJHdvcmQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCAkdGV4dCk7CgkvL9C20Yst0YjRiwogICAgJHRleHQgPSBwcmVnX3JlcGxhY2VfY2FsbGJhY2soJy8oW9CwLdGP0ZFdKig/OtC2fNGIKSko0YspKFvQsC3Rj9GRXSopL3VpJywgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbigkbWF0Y2hlcyl7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJGxldHRlciA9IGNvcHlDYXNlKCfQuCcsICRtYXRjaGVzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkd29yZCA9ICJ7JG1hdGNoZXNbMV19eyRsZXR0ZXJ9eyRtYXRjaGVzWzNdfSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICR3b3JkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgJHRleHQpOwogICAgZWNobyAkdGV4dDsKPz4=