Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Why isn't my global matching regex working?

by hippo (Bishop)
on Apr 15, 2018 at 13:07 UTC ( [id://1212927]=note: print w/replies, xml ) Need Help??


in reply to Why isn't my global matching regex working?

As I understand it, this will extract all <tr> blocks from my input.

Since you have not provided that input, we can only guess. Looking at How to ask better questions using Test::More and sample data it is simple enough to come up with a demonstration which shows that regex to work for a given set of input. Note that like brother LanX I'm going to get rid of all those backslashes.

use strict; use warnings; use Test::More tests => 4; my $input = '<html><tr>foo</tr><tr>bar</tr><tr>baz</tr></html>'; my @table = $input =~ m#(<tr.*?</tr>)#g; is $#table, 2; is $table[0], '<tr>foo</tr>'; is $table[1], '<tr>bar</tr>'; is $table[2], '<tr>baz</tr>';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1212927]
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-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found