s/(\w{3,5})\s*(\w{3})/\U$1 $2/; s/ O/ 0/; [download]
In reply to Re: UK postcode regex by Roy Johnson in thread UK postcode regex by Anonymous Monk