Skip to content

Instantly share code, notes, and snippets.

@chausen
Created March 11, 2018 17:27
Show Gist options
  • Save chausen/e2c548b6b9e80fe943c2b1d1d2089d2e to your computer and use it in GitHub Desktop.
Save chausen/e2c548b6b9e80fe943c2b1d1d2089d2e to your computer and use it in GitHub Desktop.
Regex phone number formatting in C#
using System;
using System.Text.RegularExpressions;
public class Kata
{
public static string CreatePhoneNumber(int[] numbers) =>
new Regex("(...)(...)(....)").Replace(String.Concat(numbers), "($1) $2-$3");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment