in reply to Re: Re: Regex: find/Replace words between tags (non greedy re )
in thread Regex: find/Replace words between tags

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.
  • Comment on Re: Re: Re: Regex: find/Replace words between tags (non greedy re )
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Regex: find/Replace words between tags (non greedy re )
by Anonymous Monk on Dec 16, 2001 at 02:42 UTC
    &%#$! , I just realized what is going on. Need some sleep. Please ignore previous reply,