|
Posted by Richard on 05/20/07 15:52
"cluthz" <WHATEEVVEERR@by.co.uk> wrote in message
news:JUl3i.21627$Ro3.5590@text.news.blueyonder.co.uk...
> Hi there,
>
> I have a php / mysql application where I have to change the mysql postcode
> field from being one field to two fields (for the first page and second
> part of the post code).
>
> In the database abuot 80% of fields have been entered in a good format
> having a space between the two sections.
>
> I'm going to write a script that will search for this space and divide all
> existing postcodes at the the point where this space occurs. Where there
> is no space in a postcode field. I'm just going to cut the postcode at the
> fourth character. Therefore anything past the fourth character will go
> into the second part of the field.
I would use a different splitting logic.
UK postcodes, from what I've seen, are in the form A[A]n[y] nBB
ie. The initial character string is either 1 or 2 characters, and the
characters after the A[A] are either a 1 or 2 digit number, or a 1 digit
number + 1 letter.
So it's much easier to work back from the other end. Simply find the first
digit working in from the right hand side. This is the start of the second
half. Everything before this digit will be the first half.
Unless someone knows different.
Navigation:
[Reply to this message]
|