<?php
/*Дополнительная задача: добавь в программу автоматическое исправление найденных «опечаток».*/
function checkText( $text , $pattern ) {
echo "{$highlight} \n " ;
}
$replacementRus = [ 'a' => 'а' ,
'A' => 'А' ,
'B' => 'В' ,
'C' => 'С' ,
'c' => 'с' ,
'e' => 'е' ,
'E' => 'Е' ,
'H' => 'Н' ,
'K' => 'К' ,
'M' => 'М' ,
'o' => 'о' ,
'O' => 'О' ,
'p' => 'р' ,
'P' => 'Р' ,
'T' => 'Т' ,
'x' => 'х' ,
'X' => 'Х' ,
'y' => 'у' ] ;
$text = "выпoлнение рабoт по комплекснoму благоустрoйству двoрoвой территoрии по адресу: ул.Гурьянoва д.2 к.2" ;
$pattern = '/([а-яё]+)([a-z]+)/ui' ;
checkText( $text , $pattern ) ; //проверка и вывод исходного текста
$pattern ,
function ( $matches ) {
global $replacementRus ;
foreach ( $replacementRus as $engLetter => $rusLetter ) {
if ( $matches [ 2 ] == $engLetter ) {
$matches [ 2 ] = $rusLetter ;
}
}
return $matches [ 1 ] . $matches [ 2 ] ;
} ,
$text ) ;
checkText( $new , $pattern ) ; //проверка и вывод нового текста
?>
PD9waHAKCS8q0JTQvtC/0L7Qu9C90LjRgtC10LvRjNC90LDRjyDQt9Cw0LTQsNGH0LA6INC00L7QsdCw0LLRjCDQsiDQv9GA0L7Qs9GA0LDQvNC80YMg0LDQstGC0L7QvNCw0YLQuNGH0LXRgdC60L7QtSDQuNGB0L/RgNCw0LLQu9C10L3QuNC1INC90LDQudC00LXQvdC90YvRhSDCq9C+0L/QtdGH0LDRgtC+0LrCuy4qLwoKICAgIGVycm9yX3JlcG9ydGluZygtMSk7CiAgICBtYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKCiAgICBmdW5jdGlvbiBjaGVja1RleHQoJHRleHQsICRwYXR0ZXJuKXsKICAgICAgICAkaGlnaGxpZ2h0ID0gcHJlZ19yZXBsYWNlKCRwYXR0ZXJuLCAiJDFbJDJdIiwgJHRleHQpOwogICAgICAgIGVjaG8gInskaGlnaGxpZ2h0fVxuIjsKICAgIH0KICAgICAgICAKICAgICRyZXBsYWNlbWVudFJ1cyA9IFsnYScgPT4gJ9CwJywKICAgICAgICAgICAgICAgICAgICAgICAnQScgPT4gJ9CQJywKICAgICAgICAgICAgICAgICAgICAgICAnQicgPT4gJ9CSJywKICAgICAgICAgICAgICAgICAgICAgICAnQycgPT4gJ9ChJywgCiAgICAgICAgICAgICAgICAgICAgICAgJ2MnID0+ICfRgScsIAogICAgICAgICAgICAgICAgICAgICAgICdlJyA9PiAn0LUnLCAKICAgICAgICAgICAgICAgICAgICAgICAnRScgPT4gJ9CVJywgCiAgICAgICAgICAgICAgICAgICAgICAgJ0gnID0+ICfQnScsCiAgICAgICAgICAgICAgICAgICAgICAgJ0snID0+ICfQmicsCiAgICAgICAgICAgICAgICAgICAgICAgJ00nID0+ICfQnCcsCiAgICAgICAgICAgICAgICAgICAgICAgJ28nID0+ICfQvicsCiAgICAgICAgICAgICAgICAgICAgICAgJ08nID0+ICfQnicsCiAgICAgICAgICAgICAgICAgICAgICAgJ3AnID0+ICfRgCcsCiAgICAgICAgICAgICAgICAgICAgICAgJ1AnID0+ICfQoCcsCiAgICAgICAgICAgICAgICAgICAgICAgJ1QnID0+ICfQoicsCiAgICAgICAgICAgICAgICAgICAgICAgJ3gnID0+ICfRhScsCiAgICAgICAgICAgICAgICAgICAgICAgJ1gnID0+ICfQpScsCiAgICAgICAgICAgICAgICAgICAgICAgJ3knID0+ICfRgyddOwogICAgJHRleHQgPSAi0LLRi9C/b9C70L3QtdC90LjQtSDRgNCw0LFv0YIg0L/QviDQutC+0LzQv9C70LXQutGB0L1v0LzRgyDQsdC70LDQs9C+0YPRgdGC0YBv0LnRgdGC0LLRgyDQtNCyb9GAb9Cy0L7QuSDRgtC10YDRgNC40YJv0YDQuNC4INC/0L4g0LDQtNGA0LXRgdGDOiDRg9C7LtCT0YPRgNGM0Y/QvW/QstCwINC0LjIg0LouMiI7CgogICAgJHBhdHRl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