Here is a handy regular expression that will accept many variations of an U.S. phone number, allowing the input to be somewhat flexible.
^\s*[(]?\d{3}[).\-]?\s*\d{3}(\s*|[.\-]?)\d{4}\s*$
// accepted
8015551212
801 555 1212
(801)5551212
801.555.1212
801.555-1212
801-555-1212
(801)555-1212
(801) 555-1212
801-555.1212
(801 555 1212
(801 555 1212
801)5551212
// rejected
8015551212a
80155512122
801a5551212
8015;551212
(801))5551212
Just some random development ramblings mostly related to the Microsoft .NET platform.
Wednesday, March 30, 2016
Subscribe to:
Posts (Atom)
Can't RDP? How to enable / disable virtual machine firewall for Azure VM
Oh no! I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore. I did ...
-
Oh no! I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore. I did ...
-
Here is a full test program that demonstrates how to use SharpZipLib to zip an XElement into a byte array. This allows you to transfer larg...