Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Getting + and * to generate multiple captures

by prasadbabu (Prior)
on Aug 17, 2006 at 16:17 UTC ( [id://567957]=note: print w/replies, xml ) Need Help??


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
    The problem with this is that I want each word in a separate array element. I'd have to use split() on this outer-capture and it turns out that this is not ideal for my bigger problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://567957]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found