in reply to Re: UK postcode regex
in thread UK postcode regex

A cheat that lets you avoid the /e cheat:
s/^([A-Z]{1,2}\d{1,2}[A-Z]?)\s?(O|\d)([A-Z]{2})$/\U$1 ${\(0+$2)}$3/i

Caution: Contents may have been coded under pressure.