in reply to Matching across newlines without stripping them out
The simple answer to is there a way to tell the RE engine to ignore newline characters is No.
However, I think that you are dismissing the idea of generating the regex too quickly. It is a quite legitimate thing to do. In this case I would use \s* instead of \n* if the is any chance of other whitespace that you want to ignore.
#! perl -slw use strict; my $search_string = 'uekasdh'; # Split the search string into chars and intersperse # them with the "ignore whitespace" regex. my $re = join '\s*', split '', $search_string; my $data = do{ local $/; <DATA> }; # Slurp the data $data =~ s[$re][jjjjjjjj]; # Find and replace. print $data;
|
|---|