15 Jun
2004
15 Jun
'04
9:59 a.m.
I'm having some difficulty getting my regular expression working. Basically, I need to make sure that a UK postcode is valid. The postcode that is passed to my function sometimes has extra things with it such as:
Have you looked at http://regexlib.com/REDetails.aspx?regexp_id=260 as it seems to get a high rating.
It now seems to be failing to find the postcode in the above examples. Also, when I pass my function a postcode that I know is invalid, such as JG2 7L5 it matches it as G2 7L5 instead of failing to do the match.
Try prefixing with \< to insist that the match starts at a word boundary. John.