This is a perl question, right? (I mean, you are actually using perl to run your regex over the data, aren't you?) If not, then I'm sorry I misunderstood...

Anyway, are you sure you can't use "index()", "rindex()" and "substr()" instead of regexes? (I guess "length()" could be helpful, too.) E.g.:

$bgn_target = "<!--begin node-->"; $bgn_offset = index( $_, $bgn_target ) + length( $bgn_target ); $keep_length = rindex( $_, "<!--end node-->" ) - $bgn_offset; $keep_string = substr( $_, $bgn_offset, $keep_length );
Okay, it's a bit clumsy, and could be done more compactly, but it's one way of doing the job, if it's available to you.

update: Looking at your post again, I figure the above suggestion is totally off the mark -- oh well.

Getting back to the regex... it may be that you don't need to worry at all about the stuff that precedes the first "begin node" signal -- just this much ought to match what you want to retain:

/<!--begin node-->(.*)<!--end node-->/
(that is, assuming that your regex engine -- whatever it is -- knows about using parens to capture part of a match)

When you say you can't "supply any options", does this mean you can't use use the "s" qualifier on the match (so that "." matches new-lines as well as all other characters)? Or is this not an issue for you?

(The whole setup as you describe it seems kinda cryptic and warped, like your working inside a totalitarian regime...)


In reply to Re: Must use regex, how to clip... by graff
in thread Must use regex, how to clip... by chantstophacking

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.