Hi folks,
I've sorted it, here's the sub that I'm now using:
sub splitit {
my ($line)=@_;
if ($line=~/^(.*)(\D{1,2}\d{1,2}\s{0,1}\d\D{2})\s*/) {
return ($1,$2);
} else {
return ($line,'');
}
}
Gary
On Thursday 10 Oct 2002 2:36 pm, Gary Stainburn wrote:
> Hi all,
>
> I've got a variable containing the last line of a UK postal address which
> may or may not contain a postcode. I need to remove the postcode and place
> it somewhere else and therefore think a regex of the form:
>
> if ($lastline=~/myregex/) {
> $lastline=$1;
> $postcode=$2;
> }
>
> However I'm having problems with the regex. The criteria is:
>
> The postcode may or may not have anything before it (the $1 bit)
> The postcode may only have whitespace, '.' or ',' after it (which does not
> want to be kept)
>
> The postcode is of the format
> 1 or 2 letters
> 1 or 2 numbers,
> optional space
> 1 number
> 2 letters
>
> If it is only a partial postcode it will have only up to the optional
> space. However, if this cannot be catered for, it's not the end of the
> world.
>
> Gary
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]