in reply to Re: Matching regex on multilines
in thread Matching regex on multilines
Not sure which is more efficient though...#!/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 $_;
my $result; $_ = $string ($result) = /((\w+(?=\s*))+)/s; # ((1 char) followed by # (zero or more whitespace[don't return]) # match one or more)
|
|---|