in reply to Getting + and * to generate multiple captures
Hi jgeisler
See, you have used '+' which matches the unknown number of words exactly. But if you want to capture the matched unknown words after text, you have to use another parantheses as shown below.
use strict; use warnings; my $text = 'text'; my $str = 'text some words here'; if ($str =~ /$text \s ((?: (\w+) \s?)+)/x) { print "The words after text are :$1\n"; } prints: The words after text are :some words here
Prasad
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting + and * to generate multiple captures
by jgeisler (Initiate) on Aug 17, 2006 at 17:48 UTC |