Created
January 31, 2017 14:42
-
-
Save mrcat323/513b89168aa3ce9cd3f549f1f4836b97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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