<?php

error_reporting(E_ALL);

mb_internal_encoding('utf-8');

header('Content-type: text/html;charset="utf-8"');

$challengeText = "я люблю.   мужские. члены? члены \n членики!!! да, члены.";

echo $challengeText . "\n\n";

echo preg_replace_callback('#((?:^|[.?!])\)?[\s]*)([\S])#su', function ($matches) {
	
	return $matches[1] . mb_strtoupper($matches[2]);
	
	}, $challengeText);