Does (([^\n]*[\n]){6})(.*) always matches 6 lines?

It behaves notoriously sometimes.

I have string

perl -i.bak -pe "BEGIN{undef $/;} s/\\cellx10464\\pard\\plain\\intbl\\s0\\ql\\fi0\\li0\\ri0\\sl320\\plain\\f4\\fs20\\b\\cf0 Patent Information\\b0([^\r?\n]*[\r?\n]){88}.*(EP \d{5,7})(([^\r?\n]*[\r?\n]){52}).*$2[\r\n]+\\cell\\pard\\plain\\intbl\\s0\\ql\\fi0\\li0\\ri0\\sl320\\plain\\f1\\fs20\\cf0 \\f1\\fs20\\cf0 (B\d?)[\r\n]+\\cell\\pard\\plain\\intbl\\s0\\ql\\fi0\\li0\\ri0\\sl320\\plain\\f1\\fs20\\cf0 [a-zA-Z]{3} [0-9,]{3} [0-9]{4}[\r\n]+\\cell\\pard\\plain\\intbl\\s0\\ql\\fi0\\li0\\ri0\\sl320\\plain\\f1\\fs20\\cf0 \\f1\\fs20\\cf0  [\r\n]+\\cell\\pard\\plain\\intbl\\s0\\ql\\fi0\\li0\\ri0\\plain/tttttt$2 $4/smg;" 1.rtf

My rtf contains

somestring(88 paragraphs mached as $1)(string $2)(52 paragraphs mached as string 3).*$2{means found string}[\r\n]+some string(string $4)somestring

It doesn't give the desired result. I thing it matches first occurrence of first found and last occurence of last found and removes all the lines between that are iportant one.

I am using windows strawberry perl. where am I making mistake?


In reply to Re^6: Regex find and replace involving new line by PRA007
in thread Regex find and replace involving new line by PRA007

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.