VB.Net Tutorial/Regular Expressions/Post Code — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:57, 26 мая 2010
Validate for Canada postal code format
Imports System.Text.RegularExpressions
Public Class Tester
Public Shared Sub Main
Dim sPostalCode As String = "A1A 1A1"
Dim sPattern As String
Dim objRegEx As Regex
sPattern = "[ABCEGHJKLMNPRSTVXY]\d[A-Z]\d[A-Z]\d"
Console.WriteLine(objRegEx.IsMatch(sPostalCode, sPattern))
End Sub
End Class
False
Validate for US postal code format
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