var t = ".i am krishna.   france" // string

  // regular expression to match the pattern where $1 $2 $3 are the grouping
t = t.replace(/[\n]*([a-zA-Z]+[.][ \n]*)([a-zA-Z])([a-zA-Z]*)[\n]*/, '$1' + '$2'.toUpperCase() + '$3');
 $('body').append(t);

//to convert
function convert() {
	return arguments[0].toUpperCase();
}

<html>
  <head>
    <title></title>
  </head>
  <body></body>
</html>





预期结果:

.I am krishna.  France

最佳答案

您可以使用:

t = t.replace(/(\. *)([a-z])/g, function($0, $1, $2) { return $1 + $2.toUpperCase(); });
//=> .I am krishna.   France

09-25 19:47