C#
Файл Program.cs
using System.Text.RegularExpressions;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string result = " Evgen Sunshine";
result = result.Trim();
while (true)
{
var temp = Regex.Replace(result, @"([^ ]+)( )(.{1})([*]{0,}).", "$1$2$3$4*");
// $1 it is group ([^ ]+) NOT space (1 or more times)
// $2 it is group ( ) space (1 time)
// $3 it is group (.{1}) any symbol (1 time)
// $4 it is group ([*]{0,}) symbol * (0 or more times)
// replace . it is any symbol to *
if (result == temp)
break;
result = temp;
}
// result = "Evgen S*******";
}
}
}