78065173

CSharp · Console

/Program.cs

using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;	

public class Program
{
	public static void Main()
	{
		string input = "this is your sensitive digit 12345 , if you have any question please call +91999999999999 and my home number is +123 3241 432423";

		Regex rgx = new Regex(@"\d{4,}\d");
		string replacedstar = rgx.Replace( input, "*****", 1 );
		//Console.WriteLine(replacedstar);
		Console.WriteLine(MaskDigits(input));
	}
	
	public static string MaskDigits(string input)
	{
		var split = input.Split("call");
		StringBuilder sb = new StringBuilder();
		if(split.Length > 2)
		{
			Regex rgx = new Regex(@"\d{4,}\d");
			string replacedstar = rgx.Replace( split[0], "*****");	
			return replacedstar + "call" + string.Join("", split.Skip(1).ToList());
		}
		return input;
	}
}
;