using static System.Console;
using System.Diagnostics;
using System.Text.RegularExpressions;
public static void Main() {
const int total = 1_000_000;
var cpf = "111.222.333-44";
var sw = Stopwatch.StartNew();
for (var i = 0; i < total; i++) {
formatado = cpf.Substring(0, 3) + cpf.Substring(4, 3) + cpf.Substring(8, 3) + cpf.Substring(12, 2);
WriteLine(sw.ElapsedMilliseconds);
for (var i = 0; i < total; i++) {
formatado = string.Concat(cpf.AsSpan(0, 3), cpf.AsSpan(4, 3), cpf.AsSpan(8, 3), cpf.AsSpan(12, 2));
WriteLine(sw.ElapsedMilliseconds);
for (var i = 0; i < total; i++) {
formatado = cpf[0..3] + cpf[4..7] + cpf[8..11] + cpf[12..14];
WriteLine(sw.ElapsedMilliseconds);
for (var i = 0; i < total; i++) {
var sb = new StringBuilder(cpf.Length);
foreach (var letra in cpf) if (Char.IsDigit(letra)) sb.Append(letra);
formatado = sb.ToString();
WriteLine(sw.ElapsedMilliseconds);
for (var i = 0; i < total; i++) {
formatado = string.Join("", cpf.ToCharArray().Where(Char.IsDigit));
WriteLine(sw.ElapsedMilliseconds);
for (var i = 0; i < total; i++) {
formatado = String.Join("", Regex.Split(cpf, @"[^\d]"));
WriteLine(sw.ElapsedMilliseconds);
for (var i = 0; i < total; i++) {
Regex r = new Regex(@"\d+");
foreach (Match m in r.Matches(cpf)) result += m.Value;
WriteLine(sw.ElapsedMilliseconds);