Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Capturing all instances of a repeating sub-pattern in regex

by kennethk (Abbot)
on Nov 16, 2012 at 18:41 UTC ( [id://1004231]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        $text =~ s/
              (.+?)            (?:\s*\n)+
          ((?: \d+ (?:\sPSI)? (?:\s*\n)+ ){4})
         /push @r, [ $1, $2 =~ m|\d+ (?:\sPSI)?|xg ]/esgx;
    
  2. or download this
        $text =~ s/
              (.+?)            (?:\s*\n)+
          (?: (\d+ (?:\sPSI)?) (?:\s*\n)+ )
    ...
          (?: (\d+ (?:\sPSI)?) (?:\s*\n)+ )
          (?: (\d+ (?:\sPSI)?) (?:\s*\n)+ )
         /push @r, [ $1, $2, $3, $4, $5 ]/esgx;
    
  3. or download this
        my $sub_re = qr/ (\d+ (?:\sPSI)?) (?:\s*\n)+ /x;
        $text =~ s/
              (.+?)            (?:\s*\n)+
    ...
          $sub_re
          $sub_re
         /push @r, [ $1, $2, $3, $4, $5 ]/esgx;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-19 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found