regexstringpostal-codepaf

Format Royal Mail PAF


I'm formatting addresses imported from the Sample Royal Mail PAF to Royal Mail Specification.

In the programmer's guide there are two examples with similar fields:

Table 8: Building Number in the Building Name field

Field on PAF                  Fictional example
Sub Building Name             FLAT 1
Building Name                 HOLLY HOUSE
Thoroughfare                  OAK AVENUE
Locality                      BIDDENDEN
Post Town                     ASHFORD
Postcode                      TN27 8B

Table 10: Address with Sub Building Name, & using a range in Building Name field

Field on PAF                  Fictional example
Sub Building Name             CARETAKERS FLAT
Building Name                 110-114
Thoroughfare                  HIGH STREET WEST
Post Town                     BRISTOL
Postcode                      BS1 2AW 

These should be formatted as below:

Flat 1, Holly House
Oak Avenue
Biddenden
ASHFORD
TN27 8BT 

Caretakers Flat
110-114 High Street West
BRISTOL
BS1 2AW 

What is the correct logic to determine whether the Sub Building Name should appear on the first line with the Building Name or Building Name should be on the second line with the Thoroughfare?

Note that I have tested checking for a digit in Building Name but it fails where Building Name has the value 10 Sellon Court and produces 10 Sellon Court Western Approach


Solution

  • I found the answer further in the documentation:

    Exception Rule indicators:

    i) First and last characters of the Building Name are numeric (eg ‘1to1’ or ’100:1’)

    ii) First and penultimate characters are numeric, last character is alphabetic (eg 12A’)

    iii) Building Name has only one character (eg ‘A’)