<?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/RgNCw0LLQu9GP0YLRjC4qLwplcnJvcl9yZXBvcnRpbmco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YWNlKCRwYXR0ZXJuLCAkcmVwbGFjZW1lbnQsICR0ZXh0KTsKfQoKJHJlcGxhY2VzID0gWwogICAgICAgICAgICAgICAgICAgWydwYXR0ZXJuJyA9PiAnLyjRgSnQtNC10YHRjC91aScsIAogICAgICAgICAgICAgICAgICAgICdjYWxsYmFjaycgPT4gZnVuY3Rpb24oJG1hdGNoZXMpewogICAgICAgICAgICAgICAgICAgIAlpZiAocHJlZ19tYXRjaCgnL9GBL3UnLCRtYXRjaGVzWzFdKSl7CiAgICAJCSAgICAgICAgICAgICAgICByZXR1cm4gJ9C30LTQtdGB0YwnOwogICAgCSAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgCQkgICAgICAgICAgICAgICAgcmV0dXJuICfQl9C00LXRgdGMJzsKICAgIAkgICAgICAgICAgICAgICAgfQogICAgCSAgICAgICAgICAgICB9XSwKICAgIAkgICAgICAgICAgIFsncGF0dGVybicgPT4gJy8oPzoo0Lcp0LTQtdC70LApKCg/OtGOfNC7fNC9KVxccyopL3VpJywKICAgIAkgICAgICAgICAgICAnY2FsbGJhY2snID0+IGZ1bmN0aW9uICgkbWF0Y2hlcyl7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmVnX21hdGNoKCcv0LcvdScsJG1hdGNoZXNbMV0pKXsKICAgIAkJICAgICAgICAgICAgICAgICRyZXN1bHQgPSAi0YHQtNC10LvQsHskbWF0Y2hlc1syXX0iOwogICAgCQkgICAgICAgICAgICAgICAgcmV0dXJuICRyZXN1bHQ7CiAgICAJICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAJCSAgICAgICAgICAgICAgICAkcmVzdWx0ID0gItCh0LTQtdC70LB7JG1hdGNoZXNbMl19IjsKICAgIAkJICAgICAgICAgICAgICAgIHJldHVybiAkcmVzdWx0OwogICAgCSAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfV0sCiAgICAgICAgICAgICAgICAgICBbJ3BhdHRlcm4nID0+ICcvKFvQsC3Rj9GRXSooPzrQtnzRiCkpKNGLKShb0LAt0Y/RkV0qKS91aScsCiAgICAgICAgICAgICAgICAgICAgJ2NhbGxiYWNrJyA9PiBmdW5jdGlvbiAoJG1hdGNoZXMpewogICAgCSAgICAgICAgICAgICAgICBpZiAocHJlZ19tYXRjaCgnL9GLL3UnLCRtYXRjaGVzWzJdKSl7CiAgICAJCSAgICAgICAgICAgICAgICAkcmVzdWx0ID0gInskbWF0Y2hlc1sxXX3QuHskbWF0Y2hlc1szXX0iOwogICAgCQkgICAgICAgICAgICAgICAgcmV0dXJuICRyZXN1bHQ7CiAgICAJICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAJCSAgICAgICAgICAgICAgICAkcmVzdWx0ID0gInskbWF0Y2hlc1sxXX3QmHskbWF0Y2hlc1szXX0iOwogICAgCQkgICAgICAgICAgICAgICAgcmV0dXJuICRyZXN1bHQ7CiAgICAJICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9XQogICAgICAgICAgICAgICBdOwpmb3JlYWNoICgkcmVwbGFjZXMgYXMgJHJlcGxhY2UpewoJJHRleHQgPSBwcmVnX3JlcGxhY2VfY2FsbGJhY2soJHJlcGxhY2VbJ3BhdHRlcm4nXSwgJHJlcGxhY2VbJ2NhbGxiYWNrJ10sICR0ZXh0KTsKfQoKZWNobyAkdGV4dDs=