Hello All,
I have an array with the following lines, that always follow this format. I
need a regular expression that will just pull the data at the end of the
sentence. For example, only AZID, IA, KSOK, MO, NVUT, OR.
The Wall will tell ME to update AZID.
The Wall will tell ME to update IA.
The Wall will tell ME to update KSOK.
The Wall will tell ME to update MO.
The Wall will tell ME to update NVUT.
The Wall will tell ME to update OR.
William Black
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
"William Black" <wjblack74@no-spam> wrote in message news:Law15-F37BCPWaJUYcA0003a316@no-spam
> Hello All,
>
> I have an array with the following lines, that always follow this format. I
> need a regular expression that will just pull the data at the end of the
> sentence. For example, only AZID, IA, KSOK, MO, NVUT, OR.
>
> The Wall will tell ME to update AZID.
> The Wall will tell ME to update IA.
> The Wall will tell ME to update KSOK.
> The Wall will tell ME to update MO.
> The Wall will tell ME to update NVUT.
> The Wall will tell ME to update OR.
Hi William.
What you write depends on whether you want to /check/ the contents
of the data or simply extract the final word.
This program will extract the last complete word from any array of
strings, but won't check that the string started with
'The Wall will tell ME to update '
is this what you want?
HTH,
Rob
use strict;
use warnings;
my @no-spam = (
'The Wall will tell ME to update AZID.',
'The Wall will tell ME to update IA.',
'The Wall will tell ME to update KSOK.',
'The Wall will tell ME to update MO.',
'The Wall will tell ME to update NVUT.',
'The Wall will tell ME to update OR.',
);
my @no-spam = map /.*\b(\w+)/, @no-spam
print "$_\n" foreach @no-spam
OUTPUT
AZID
IA
KSOK
MO
NVUT
OR