.NET Fiddle

CSharp · Console

/Program.cs

using System;

using System.Text.RegularExpressions;
					
public class Program
{
	public static void Main() {

	
		string s2 = Regex.Replace("abcdefghik", @"b(.)d", cb =>
								  
									  " hahah " + cb.Groups[1].Value + " heheh "
								  );
		
		Console.WriteLine(s2);		
	}
	
}
;