PERL BEGINNERS 36 RE HELP
Subject: re: Help
Date: Fri, 08 Aug 2003 09:40:20 -0400

From: wjblack74@no-spam (William Black)

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

Subject: Re: Help
Date: Fri, 8 Aug 2003 14:51:54 +0100




From: rob@no-spam (Rob Dixon)
"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