CFLib.org – Common Function Library Project

IsZIPUK(str)

Last updated October 30, 2008

author

Duncan

Version: 2 | Requires: CF5 | Library: StrLib

Description:
Tests passed value to see if it is a properly formatted U.K. postcode (zip code). Does not check actual validity/existence of zip code!

Return Values:
Returns a Boolean.

Example:

<cfoutput>
OX4 1XP: #YesNoFormat(IsZipUK("OX4 1XP"))#<br>
OX11 0AL: #YesNoFormat(IsZipUK("OX11 0AL"))#<br>
O11 0AS: #YesNoFormat(IsZipUK("O11 0AS"))#<br>
RG1 AP: #YesNoFormat(IsZipUK("RG1 AP"))#<br>
</cfoutput>

Parameters:

Name Description Required
str String to be checked. Yes

Full UDF Source:

/**
 * Tests passed value to see if it is a properly formatted U.K. postcode (zip code).
 * v1 by Robert West
 * 
 * @param str 	 String to be checked. (Required)
 * @return Returns a Boolean. 
 * @author Duncan (duncan@duncancumming.co.uk) 
 * @version 2, October 30, 2008 
 */
function IsZipUK(str) {
return REFind("(GIR 0AA)|((([ABCDEFGHIJKLMNOPRSTUWYZ][0-9][0-9]?)|(([ABCDEFGHIJKLMNOPRSTUWYZ][ABCDEFGHKLMNOPQRSTUVWXY][0-9][0-9]?)|(([ABCDEFGHIJKLMNOPRSTUWYZ][0-9][ABCDEFGHJKSTUW])|([ABCDEFGHIJKLMNOPRSTUWYZ][ABCDEFGHKLMNOPQRSTUVWXY][0-9][ABEHMNPRVWXY])))) [0-9][ABDEFGHJLNPQRSTUWXYZ]{2})", str);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson