using System.Diagnostics;
using System.Text.RegularExpressions;
string input = "OPEN GIRL, I will make you Happy Everyday...😋😋😋 I'm looking for a man who can appreciate me . Kisses. OPEN GIRL, I will make you Happy Everyday...😋😋😋 I'm looking for a man who can appreciate me . Kisses. OPEN GIRL, I will make you Happy Everyday...😋😋😋 I'm looking for a man who can appreciate me . Kisses. OPEN GIRL, I will make you Happy Everyday...😋😋😋 I'm looking for a man who can appreciate me . Kisses";
const int iterations = 5;
long totalElapsedTimeWrap = 0;
long totalElapsedTimeRemove = 0;
string pattern = @"\p{Cs}|\p{Co}\p{Cf}*";
Regex regex = new Regex(pattern);
string replacePattern = @"<nt>|</nt>";
Regex replaceRegex = new Regex(replacePattern);
for (int i = 0; i < iterations; i++)
Stopwatch stopwatchWrap = Stopwatch.StartNew();
for (int j = 0; j < 100000; j++)
wrappedText = WrapEmojisWithTag(input, regex);
totalElapsedTimeWrap += stopwatchWrap.ElapsedMilliseconds;
Stopwatch stopwatchRemove = Stopwatch.StartNew();
for (int j = 0; j < 100000; j++)
result = RemoveXmlTags(input, replaceRegex);
totalElapsedTimeRemove += stopwatchRemove.ElapsedMilliseconds;
Console.WriteLine($"Iteration {i + 1}: Wrap Elapsed time: {(double)stopwatchWrap.ElapsedMilliseconds / 100000} ms, Remove Elapsed time: {stopwatchRemove.ElapsedMilliseconds} ms");
double averageElapsedTimeWrap = (double)totalElapsedTimeWrap / iterations / 100000;
double averageElapsedTimeRemove = (double)totalElapsedTimeRemove / iterations / 100000;
Console.WriteLine($"Average Wrap Elapsed Time: {averageElapsedTimeWrap} ms");
Console.WriteLine($"Average Remove Elapsed Time: {averageElapsedTimeRemove} ms");
Console.WriteLine($"WrappedText: {wrappedText}");
Console.WriteLine($"Result: {result}");
static string WrapEmojisWithTag(string input, Regex regex)
string result = regex.Replace(input, match => $"<nt>{match.Value}</nt>");
static string RemoveXmlTags(string input, Regex regex)
string result = regex.Replace(input, match => String.Empty);