replace duplicate characters with ##

CSharp · Console

/Program.cs

using System;
using System.Text.RegularExpressions;
					
public class Program
{
	public static void Main()
	{
		var rex = new Regex(@"(.)\1");
		var replaced = rex.Replace("99988", "##");
		
		Console.WriteLine(replaced); // -> ##9##
	}
}
;