eric-perl wrote at Tue, 10 Sep 2002 09:32:22 +0200:

> 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'

As TMTWTDI, here's a solution without a global matching:

my @at_words = grep /at/, split /\W+/, $sentence;


Greetings,
Janek


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

Reply via email to