Created
March 11, 2018 17:27
-
-
Save chausen/e2c548b6b9e80fe943c2b1d1d2089d2e to your computer and use it in GitHub Desktop.
Regex phone number formatting in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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