在点之后大写并且 space 仅在点之后的下一个单词(可能是 regex + ucfirst )

Capitalize after point and space only the next word after point ( maybe regex + ucfirst )

点后大写,space仅点后的下一个单词,可能使用正则表达式 + ucfirst..

preg_match('/[\s\.][a-z]/'
$theCode = str_replace(ucfirst.....

总结就是在spaço + point之后的第一个字母,在变量的所有数据中只做大写。

$theCode = 'babab. babab babab. bababa bababa bababa. bababa babab baba';

输出:

$theCode = 'babab. Babab babab. Bababa bababa bababa. Bababa babab baba';

不管我采用什么方法,我只是建议。

谢谢

对于php,preg_replace_callback + ucfirst

live example

$theCode = 'babab. babab babab. bababa bababa bababa. bababa babab baba';
$pattern = '/([a-z][^.]*)/i';

$result = preg_replace_callback($pattern, function($matches) {
    return ucfirst($matches[0]);
}, $theCode);

echo $result;

对于javascript,

function capitalizeAll(str) {
   return str.replace(/([a-z])([^.]*)/gi, (a, b, c) => {
      return (b || '').toUpperCase() + c;
   });
}

var theCode = 'babab. babab babab. bababa bababa bababa. bababa babab baba';

console.log(capitalizeAll(theCode));