Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
\b((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))\b |
Description |
This is my attempt to find out valid german postal codes (PLZ or Postleitzahlen).
After the German Unification the numbers were changed to a five digit system. The postal codes starts with the two digit "Leitzahl". This is a number between 00 and 99 excluding the not yet used numbers: 00, 05, 43 and 62! After that follows directly a three digit number, 000-999.
Comments welcome. This works for me, however I think it could be written more compact, but could not figure out how ;-)
For more information on german postal codes see:
http://de.wikipedia.org/wiki/Liste_der_Postleitbereiche_Deutschland
http://de.wikipedia.org/wiki/Postleitzahl_%28Deutschland%29
http://en.wikipedia.org/wiki/List_of_postal_codes_in_Germany |
Matches |
12556 | 01550 | 80796 |
Non-Matches |
05234 | 8973 | 62980 |
Author |
Rating:
Markus Matern
|
Title |
Test
Details
Pattern Title
|
Expression |
(((^[BEGLMNS][1-9]\d?) | (^W[2-9] ) | ( ^( A[BL] | B[ABDHLNRST] | C[ABFHMORTVW] | D[ADEGHLNTY] | E[HNX] | F[KY] | G[LUY] | H[ADGPRSUX] | I[GMPV] | JE | K[ATWY] | L[ADELNSU] | M[EKL] | N[EGNPRW] | O[LX] | P[AEHLOR] | R[GHM] | S[AEGKL-PRSTWY] | T[ADFNQRSW] | UB | W[ADFNRSV] | YO | ZE ) \d\d?) | (^W1[A-HJKSTUW0-9]) | (( (^WC[1-2]) | (^EC[1-4]) | (^SW1) ) [ABEHMNPRVWXY] ) ) (\s*)? ([0-9][ABD-HJLNP-UW-Z]{2})) | (^GIR\s?0AA) |
Description |
Here it is, the monster UK Postcode regular expression that should prevent the majority of miskeying. Unlike an most other regexes it only permits valid combinations of letters, e.g. BN works, BM does not. Spaces between the first and second parts are optional. I have tested this against a file of 7,500 valid postcodes, and also against a real-world list of about 12,000 which had some bad data. Manually checking a sample of the rejected ones showed it was working correctly (and how poor the data was!!).
I originally started by trying to adapt the GDSC document at http://www.govtalk.gov.uk/gdsc/html/frames/PostCode.htm and specifically their XSD pattern at http://www.govtalk.gov.uk/gdsc/schemaHtml/bs7666-v2-0-xsd-PostCodeType.htm but this turned out to be rather loose. Instead I wrote this. If you find any valid postcodes being rejected by this regex please let me know. |
Matches |
W1A 1AA | EC2V 1JN | GIR 0AA |
Non-Matches |
TB12 1AB | EC2V 1JM | W2A 1AA |
Author |
Rating:
Howard Richards
|
Title |
Test
Details
Pattern Title
|
Expression |
^\({0,1}0(2|3|7|8)\){0,1}(\ |-){0,1}[0-9]{4}(\ |-){0,1}[0-9]{4}$ |
Description |
Expression to parse Australian landline telephone numbers. Will only accept valid STD codes. Allows for brackets around the STD code and either spaces or dashes between number groups. |
Matches |
(02) 9323 1234 | 0293231234 | 02-9323-1234 |
Non-Matches |
01 9323 1234 | 02 932 123 | 02/9323/1234 |
Author |
Rating:
Not yet rated.
Ben Vaughan
|
Title |
Test
Details
Pattern Title
|
Expression |
(((^[BEGLMNS][1-9]\d?)|(^W[2-9])|(^(A[BL]|B[ABDHLNRST]|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]|F[KY]|G[LUY]|H[ADGPRSUX]|I[GMPV]|JE|K[ATWY]|L[ADELNSU]|M[EKL]|N[EGNPRW]|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKL-PRSTWY]|T[ADFNQRSW]|UB|W[ADFNRSV]|YO|ZE)\d\d?)|(^W1[A-HJKSTUW0-9])|(((^WC[1-2])|(^EC[1-4])|(^SW1))[ABEHMNPRVWXY]))(\s*)?([0-9][ABD-HJLNP-UW-Z]{2}))$|(^GIR\s?0AA$) |
Description |
For the terminally hard of thinking, a version of my UK postcode validator without WHITESPACE. Unlike most validators on regexlib, this knows valid postcode combinations, e.g. W1A is permitted, W1 is not, but W2 is. It should catch between 95-98% of invalid postcodes. |
Matches |
W1A 1AA | EC1V1JN | N7 8BQ |
Non-Matches |
W1A 1AM | BM1 1AB | EC1 1AA |
Author |
Rating:
Howard Richards
|
Displaying page
of
pages;
Items to