Let's say I've got the following string in a file:
"skkjnfinduekasdhelkjadfoijejdklk"
Between each character in the string, there can be zero or more newlines. So the file could look something like this:
s
kkjn




find
ue
k


asd
helkjadfoijejdklk
My question is, is there a way to tell the RE engine to ignore newline characters so I don't have to write
/u\n*e\n*k\n*a\n*s\n*d\n*h\n*/
to match the string
"uekasdh"
?

While the above is simple enough to type for a short string, for longer ones I'd have to use function to generate the RE which seems a little too weird.

IMPORTANT NOTE: I would like to be able to replace a string like "ue\nk\n\n\nasd\nh" in the example file above with another string like "jjjjjjj" but I want to keep the other the newlines in the file in tact. In other words, I want to avoid stripping the newlines out of the file to do the search.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop";
$nysus = $PM . $MCF;
Click here if you love Perl Monks


In reply to Matching across newlines without stripping them out by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.