Windows Phone Developers

Sunday, June 1, 2008

Regular Expression to Check Zip Code

Regular Expression to Match Zip Code

Imports System.Text.RegularExpressions

Function IsValidZip(ByVal sZipCode As String)

Return Regex.IsMatch(sZipCode, "^\d{5}(\-\d{4})?$")

End Function

The above will check for U.S . Zip codes like 55001-2434. 94941-3232 etc

To Check Indian Zip codes use

Imports System.Text.RegularExpressions

Function IsValidZip(ByVal sZipCode As String)

Return Regex.IsMatch(sZipCode, "^\d{6}$")

End Function

Matches 600040, 400123 etc

See Also
Extract Ref Links From WebPage using VB.Net Regular Expressions
Remove HTML Tags from String using .NET Regular Expressions
VB.NET Regular Expression to Check URL
VB.NET Regular Expression to Check Email Addresses
VB.NET Regular Expression to Check MAC Address
Regular Expression to Check Zip Code
Validate eMail Addresses using VB.NET Function
Regular Expressions in Dot Net (.NET)

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

1 comment:

  1. Hi Everyone,

    The Regular Expression for Indian PIN code is as below.

    ReplyDelete