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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|