<?php
/*Если ты сделал задачу про Grammar Nazi, сделай скрипт, которы вместо сообщения об ошибках будет молча
их исправлять.*/
$text = "Привет,Жырный!труд:Шырокий?пассаЖЫР;зделаю Координально но, например Сдесь сдесь решена проблема ушыбов.
Зделано многое а? ведь эти ушы зделали мы. Один ананас но зато какой" ;
$simpleReplace = [ '/(к)оординально/ui' => '$1ардинально' , //кардинально
'/([,;!?:])([^,;!?:\\s]+)/u' => '$1 $2' , //пробелы после знаков препинания
'/([а-яё]+)\\s+((?:а|но)[^а-яё])/ui' => '$1, $2' ] ; //знаки препинания
foreach ( $simpleReplace as $pattern => $replacement ) {
}
$replaces = [
[ 'pattern' => '/(с)десь/ui' ,
'callback' => function ( $matches ) {
return 'здесь' ;
} else {
return 'Здесь' ;
}
} ] ,
[ 'pattern' => '/(?:(з)дела)((?:ю|л|н)\\s*)/ui' ,
'callback' => function ( $matches ) {
$result = "сдела{$matches[2]} " ;
return $result ;
} else {
$result = "Сдела{$matches[2]} " ;
return $result ;
}
} ] ,
[ 'pattern' => '/([а-яё]*(?:ж|ш))(ы)([а-яё]*)/ui' ,
'callback' => function ( $matches ) {
$result = "{$matches[1]} и{$matches[3]} " ;
return $result ;
} else {
$result = "{$matches[1]} И{$matches[3]} " ;
return $result ;
}
} ]
] ;
foreach ( $replaces as $replace ) {
}
echo $text ;
PD9waHAKLyrQldGB0LvQuCDRgtGLINGB0LTQtdC70LDQuyDQt9Cw0LTQsNGH0YMg0L/RgNC+IEdyYW1tYXIgTmF6aSwg0YHQtNC10LvQsNC5INGB0LrRgNC40L/Rgiwg0LrQvtGC0L7RgNGLINCy0LzQtdGB0YLQviDRgdC+0L7QsdGJ0LXQvdC40Y8g0L7QsSDQvtGI0LjQsdC60LDRhSDQsdGD0LTQtdGCINC80L7Qu9GH0LAK0LjRhSDQuNGB0L/RgNCw0LLQu9GP0YLRjC4qLwplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTs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ICcvKNGBKdC00LXRgdGML3VpJywgCiAgICAgICAgICAgICAgICAgICAgJ2NhbGxiYWNrJyA9PiBmdW5jdGlvbigkbWF0Y2hlcyl7CiAgICAgICAgICAgICAgICAgICAgCWlmIChwcmVnX21hdGNoKCcv0YEvdScsJG1hdGNoZXNbMV0pKXsKICAgIAkJICAgICAgICAgICAgICAgIHJldHVybiAn0LfQtNC10YHRjCc7CiAgICAJICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAJCSAgICAgICAgICAgICAgICByZXR1cm4gJ9CX0LTQtdGB0YwnOwogICAgCSAgICAgICAgICAgICAgICB9CiAgICAJICAgICAgICAgICAgIH1dLAogICAgCSAgICAgICAgICAgWydwYXR0ZXJuJyA9PiAnLyg/OijQtynQtNC10LvQsCkoKD860Y580Lt80L0pXFxzKikvdWknLAogICAgCSAgICAgICAgICAgICdjYWxsYmFjaycgPT4gZnVuY3Rpb24gKCRtYXRjaGVzKXsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByZWdfbWF0Y2goJy/Qty91JywkbWF0Y2hlc1sxXSkpewogICAgCQkgICAgICAgICAgICAgICAgJHJlc3VsdCA9ICLRgdC00LXQu9CweyRtYXRjaGVzWzJdfSI7CiAgICAJCSAgICAgICAgICAgICAgICByZXR1cm4gJHJlc3VsdDsKICAgIAkgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgIAkJICAgICAgICAgICAgICAgICRyZXN1bHQgPSAi0KHQtNC10LvQsHskbWF0Y2hlc1syXX0iOwogICAgCQkgICAgICAgICAgICAgICAgcmV0dXJuICRyZXN1bHQ7CiAgICAJICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9XSwKICAgICAgICAgICAgICAgICAgIFsncGF0dGVybicgPT4gJy8oW9CwLdGP0ZFdKig/OtC2fNGIKSko0YspKFvQsC3Rj9GRXSopL3VpJywKICAgICAgICAgICAgICAgICAgICAnY2FsbGJhY2snID0+IGZ1bmN0aW9uICgkbWF0Y2hlcyl7CiAgICAJICAgICAgICAgICAgICAgIGlmIChwcmVnX21hdGNoKCcv0YsvdScsJG1hdGNoZXNbMl0pKXsKICAgIAkJICAgICAgICAgICAgICAgICRyZXN1bHQgPSAieyRtYXRjaGVzWzFdfdC4eyRtYXRjaGVzWzNdfSI7CiAgICAJCSAgICAgICAgICAgICAgICByZXR1cm4gJHJlc3VsdDsKICAgIAkgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgIAkJICAgICAgICAgICAgICAgICRyZXN1bHQgPSAieyRtYXRjaGVzWzFdfdCYeyRtYXRjaGVzWzNdfSI7CiAgICAJCSAgICAgICAgICAgICAgICByZXR1cm4gJHJlc3VsdDsKICAgIAkgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH1dCiAgICAgICAgICAgICAgIF07CmZvcmVhY2ggKCRyZXBsYWNlcyBhcyAkcmVwbGFjZSl7CgkkdGV4dCA9IHByZWdfcmVwbGFjZV9jYWxsYmFjaygkcmVwbGFjZVsncGF0dGVybiddLCAkcmVwbGFjZVsnY2FsbGJhY2snXSwgJHRleHQpOwp9CgplY2hvICR0ZXh0Ow==