Skip to content

Instantly share code, notes, and snippets.

@mrcat323
Created January 31, 2017 14:42
Show Gist options
  • Save mrcat323/513b89168aa3ce9cd3f549f1f4836b97 to your computer and use it in GitHub Desktop.
Save mrcat323/513b89168aa3ce9cd3f549f1f4836b97 to your computer and use it in GitHub Desktop.
<?php
mb_internal_encoding('UTF-8');
$input = 'привет, мир. я программист PHP. это правда! не вру!';
function text($input)
{
return preg_replace_callback('#((?:[.!?]|^)\s*)(\w)#us', function($matches) {
return $matches[1] . mb_strtoupper($matches[2]);
}, $input);
}
$actualOutput = text($input);
$expectedOutput = 'Привет, мир. Я программист PHP. Это правда! Не вру!';
var_dump($actualOutput == $expectedOutput);
echo $actualOutput . PHP_EOL;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment