in reply to Getting + and * to generate multiple captures
Have you tried split?
use strict; use warnings; my $msg = "the quick brown fox jumps over the lazy dog"; my $text = "fox"; my @words = ( ); if ($msg =~ /$text \s (((\w+) \s?)+)/x) { @words = split(/\s+/, $1); # @words now contains the list you want... printf "Words: %s\n", join(',', @words); } __END__ [Results] Words: jumps,over,the,lazy,dog
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting + and * to generate multiple captures
by jgeisler (Initiate) on Aug 17, 2006 at 18:00 UTC |