in reply to RegEx ignoring intervening characters?
You could do something like this:
And an alternate way of forming the pattern:use strict; use warnings; my $stuff = qr/[^A-Z]*/; my $regex = qr{ A $stuff B $stuff C $stuff D }x; while (my $line = <DATA>) { if ($line =~ $regex) { print "Matched: $line"; } } __DATA__ ABhere is intervening textC D A B C, lots of text and numbers and equals and slashes DEFG ABhere IS intervening TEXTC D
my $stuff = qr/[^A-Z]*/; my $regex = join($stuff, split '','ABCD');
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: RegEx ignoring intervening characters?
by ww (Archbishop) on Jan 19, 2007 at 22:17 UTC |
In Section
Seekers of Perl Wisdom