-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 12:32 AM
To: Beginners Perl Mailing List
Subject: Regular Expressions: Grouping and backreferences...


Hello, All:

How can I capture all the words that contain 'at' in the string 'A fat cat
sat on my hat.'?

Any pointers?

$sentence = 'A fat cat sat on my hat.'
$sentence =~ m/(\wat)/;

.....returns:

$1 = 'fat'

-----Response Message-----

your regex will only match the letter before at and the 'at', all words
containing 'at' is the following, placing them into the array called @list:

$sentence = 'A fat cat sat on that hat.';
@list = $sentence =~ m/(\w*at\w*)/g;

foreach (@list) {print "$_\n"}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to