DOOOH! I seemed to have missed something. I don't mean to be a pest, but something is not making sense. Anyway, I have made a few renditions of the code offered and every example seems to suffer from a greed problem. I have inserted a while loop to have the regex range over the data until all instances of wirey have been removed between the approprite tags. The same happens w/o the while loop if the in.txt looks like this:
sample in.txt
blah...blah...blah
BEGTITLE My dog is stinkey ENDTITLE
BEGTEXT My dog has wirey hair ENDTEXT
BEGTITLE My dog's name is skip ENDTITLE
blah...blah...blah
The problem enters when wirey is replaced in the TEXT field. The code seems to gravitate towards testing the last instance of ENDTITLE rather that the 1st. Is this a nesting Issue? I was thinking that nesting is like this .BEGTITLE title BEGTITLE title2 ENDTITLE ENDTITLE, where there is not a balanced symmetry like you might find in a comma delimited file. In my case there is always a ENDTITLE before the appearence of the 2nd+ instance of a BEGTITLE tag.
Thanks. I am just trying to learn as much of this as I can.
I thought the (.*?) usage would keep the script from being greedy like this.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.