Sorry, I have now fixed it ( It was looking me straight in the face),
I forgot to remove the escape character, from the white space match,
it should be reading:

Reg.SearchPattern = "^[A-Z]{1,2}[0-9][0-9A-Z]?\s+[0-9][ABD-HJLNP-UW-Z] {2}$"

Sorry to waste anyones time.

Mark

On 16 Feb 2006, at 21:58, Mark Cooke wrote:

Hi,

I'm have a small problem trying to validate a UK Postcode, I've ported over several regex searches from some of my PHP scripts, to validate things like e-mail addresses, etc.. But for some reason I'm unable to get my UK Postcode validation to work.

// Declare and Initialize the variables to use.
Dim Reg as New RegEx
Dim FoundMatch  as New RegExMatch

// UK Post Code search pattern
Reg.SearchPattern = "^[A-Z]{1,2}[0-9][0-9A-Z]?\\s+[0-9][ABD-HJLNP- UW-Z]{2}$"

// Check for a match on Post Code
FoundMatch = Reg.Search( "GL2 4XR"  )

// Check to see if we have found a match
if ( FoundMatch <> nil ) then
MsgBox "Match"
Else
MsgBox "No Match"
End If

Could anyone advise me where I may be going wrong.

Thanks

Mark
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to