Validate for US postal code format : Post Code « Regular Expressions « VB.Net Tutorial






Imports System.Text.RegularExpressions

Public Class Tester
    Public Shared Sub Main
        Dim sPostalCode As String = "12345-1111"
        Dim sPattern As String
        Dim objRegEx As Regex

        sPattern = "\d\d\d\d\d-\d\d\d\d"
        
        Console.WriteLine(objRegEx.IsMatch(sPostalCode, sPattern))
    End Sub
End Class
True








20.5.Post Code
20.5.1.Validate for US postal code format
20.5.2.Validate for Canada postal code format