Can someone please help me - I need to write a function that will validate UK postcodes written in a textbox but every tutorial and example source code I find for it is in other languages such as VB and Javascript.
The VB code looks extremely small:
1.
Public Function isValidPostCode(ByVal input As String) As Boolean
2.
3.
Dim validInput As Boolean = False
4.
5.
' Check that the input is not null before checking
6.
If input IsNot Nothing Then
7.
8.
' Regex from: http://www.cabinetoffice.gov.uk/media/291370/bs7666-v2-0-xsd-PostCodeType.htm
9.
validInput = Regex.IsMatch(input, "^(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})$", RegexOptions.IgnoreCase)
10.
11.
End If
12.
13.
Return validInput
14.
15.
End Function
Is there a way this could be convereted for use in Delphi database?