in reply to Re: Matching regex on multilines
in thread Matching regex on multilines

As davido and BUU referred to here's an example...
If your input file isn't too big you could do something like this...
#!/usr/bin/perl -W use strict; my $string = <<HERE; abc defg hijk lm no pqr stu vwkyz HERE my $find = "hijklmnop"; # get a copy to avoid modifying orig $_ = $string; # remove all spaces s/\s//gs; # note the /s that davido referred to print "Matched!\n" if $_ =~ $find; # to see what the subst did. print $_;
Not sure which is more efficient though...

Also, it seems like you could do something like this, never modifying the orig string...
But I couldn't get it to work. May the gurus can help...
my $result; $_ = $string ($result) = /((\w+(?=\s*))+)/s; # ((1 char) followed by # (zero or more whitespace[don't return]) # match one or more)