0
votes

I would like to know if there is a way to split correctly UK postcodes using XSLT 1.0.

For example:

PE92BD --> PE9 2BD
NE611PE --> NE61 1PE 
CV364AB --> CV36 4AB
SN13EG --> SN1 3EG
IP242AN --> IP24 2AN
1
What are the rules? Does the second part always consist of the last three characters?Martin Honnen
yes the second part is always 3 characters as the sector of UK postcode is 0-9kokos
@kokos Is your question not answered then?michael.hor257k
No is not answeredkokos
@kokos Why not? What's missing?michael.hor257k

1 Answers

3
votes

I would like to know if there is a way to split correctly UK postcodes using XSLT 1.0.

Assuming that by "split correctly" you mean place a space before the last three characters, you can do:

<xsl:variable name="length" select="string-length($postcode)" />    
<xsl:value-of select="substring($postcode, 1, $length - 3)"/>
<xsl:text> </xsl:text>
<xsl:value-of select="substring($postcode, $length - 2)"/>