Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Behavior of /g when there are capture groups (join)

by tye (Sage)
on Apr 21, 2016 at 14:54 UTC ( [id://1161103]=note: print w/replies, xml ) Need Help??


in reply to Behavior of /g when there are capture groups

my @groups = ( 'fo.', '.­*?', 'ba.' ); my $find = join '', @groups; my $capture = join '', map "($_)", @groups; my $fc = read_my_file(); my @excerpts = $fc =~ /$find/g; my @parts = $excerpts[0] =~ /$capture/;

[Updated: Changed [ ... ] to ( ... ) on the first line -- thanks for the private correction.]

- tye        

Replies are listed 'Best First'.
Re^2: Behavior of /g when there are capture groups (join)
by ExReg (Priest) on Apr 21, 2016 at 15:31 UTC

    Nice succinct way of constructing the two regexes from one source. I think that may do the trick.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-16 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found