thanks for all ur suggestions. Can u please give me the sample code for ur solution.
Thanks >On 11/14/06, Peter Boughton <[EMAIL PROTECTED]> wrote: >> Ah, I knew I was missing something. >> ....but... you can prevent that with a negative lookahead. :) >> Something along the lines of. >> <Emphasis type="([a-z])[^"]+">([^<]|<(?!Emphasis))+?</Emphasis> >> So it only matches Emphasis tags that do not themselves contain the >> <Emphasis string. >> That should work, right? (inside an appropriate cfloop) > >In a pure world, then maybe. But in the world created by this >example, the tags *do* contain other tags of the same type. This >would match a tag if, and only if, it did *not*. The tags wouldn't >get replaced if other tags of the same type were nested inside. > >The regex you applied would, in effect, find the innermost Emphasis >tag of a particular group, but there may be many levels of nest and >even many adjacent tags. Everything isn't quite that neat, I don't >think. :-) > >Given: > ><Book> ><Emphasis type="Bold"> >sample text > <Emphasis type="Italic"> > sample Text > <Emphasis type="underline"> > sample text > </Emphasis> > </Emphasis> >sample text ></Emphasis> ><Emphasis type="Bold"> >sample text > <Emphasis type="Italic"> > sample Text > <Emphasis type="underline"> > sample text > </Emphasis> > </Emphasis> >sample text ></Emphasis> ></Book> > >Your regex would find the innermost tag of the first group, but >without the help of additional code it wouldn't be able to adjust to >the next, non-nested group nor would it be able to jump to the >adjacent group. > >I think you're right - it could be done, but it doesn't seem as >intuitive to my brain. To me it's easier to find a particular tag >(using /<Emphasis type="[a-z]+">/ or whatever regex) and from the end >point of that tag look for /<\/?Emphasis>/. If you encounter another >open Emphasis tag, increment the counter, if you encounter a close >Emphasis tag and the counter is "0" then you've found the end tag >you're looking for, else decrement the counter. > >Like anything else, I guess: there's more than one way to do it. I >just can't quite wrap my brain around the way you're proposing. :-) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:992 Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21
