Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Phone number regex validator
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here var regex = @"^(?<countryCode>[\+][1-9]{1}[0-9]{0,2}\s)?(?<areaCode>0?[1-9]\d{0,4})(?<number>\s[1-9][\d]{5,12})(?<extension>\sx\d{0,4})?$"; var phones = new [] { "02 5555555 x4545", "054 5575487", "02 5555555", "054 5575487", "+1 212 7777777", "212 7777777", "+44 7777 777-777", "+44 20 44444444", "07777 777777", "020 44444444" }; foreach(var phone in phones) Console.WriteLine(Regex.IsMatch(phone, regex)); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Math 5.81
hackton
test type casting
vera
transform string to hex code
Working (C# thing)
2.1 Basic types: Lists and Linq beauty
Min max elements swap of the array
SHA Tester 2.0
Remove Duplicates from a string
Please log in to post a comment.