in reply to substitute instead global matching for nested matches
Think lines and grab just those you want. Consider:
use strict; use warnings; my $fc = <<FC; #4 r0 ! r1 ! r2 ! #5 r3 ! r4 ! r5 ! FC print "$1\n$2\n" while $fc =~ /^(#\d+).*?^.*?^(.*?)$/gms;
Prints:
#4 r0 ! #5 r3 !
Note the regex switches - g to match multiple times, s to let . match new line characters, and m to perform a multi-line match which allows the internal ^ and $ matches to work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitute instead global matching for nested matches
by utku (Acolyte) on Mar 18, 2012 at 23:06 UTC | |
by GrandFather (Saint) on Mar 18, 2012 at 23:19 UTC | |
by utku (Acolyte) on Mar 18, 2012 at 23:27 UTC |