I'm guessing your problem is with greedy matching.
Your current regex will look like this: (partone).*(parttwo)
It should look like this: (partone).*?(parttwo)
(not the question mark after the asterisk)

Also, if you're doing this in three steps, you'll want to do it in one.
Actually, here we go, have a try with this...
Search:
<Emphasis type="([biuBIU])[^"]*">(.*?)</Emphasis>
Replace:
<\1>\2</\1>

(or <$1>$2</$1> if you're using something that uses dollars rather than slashes)

Not sure if you'll need to wrap that in a while-loop to guarantee
everything gets replaced.


Hmmm, odd - I just decided to quickly test that, and it only worked
without the non-greedy modifier. ie: this worked:
<cfloop condition="#REFind('<Emphasis type="([biuBIU])[^"]*">',X)#">
        <cfset X = REReplace(X,'<Emphasis
type="([biuBIU])[^"]*">(.*)</Emphasis>',"<\1>\2</\1>","all")/>
</cfloop>

But I'm not sure if I'm starting to fall asleep, so it is possible I'm
making some huge mistake somewhere here. :/

Anyhow, hopefully I've not completely confused you and something I've
written is able to help. :)

Peter

On 11/14/06, mira mira <[EMAIL PROTECTED]> wrote:
> hi
>
> I have problem in writing Regex.
>
> This is my sample xml code
> **************************
> <Book>
> <Emphasis type="Bold">
> sample text
>   <Emphasis type="Italic">
>    sample Text
>         <Emphasis type="underline">
>             sample text
>         </Emphasis>
>   </Emphasis>
> sample text
> </Emphasis>
> </Book>
>
> I need to write regex for replacing the Emphasis tags.
> that is i need to replace the following tags:
> <Emphasis type="Bold"></Emphasis> with <B></B>
> <Emphasis type="Italic"></Emphasis> with<I></I>
> <Emphasis type="underline"></Emphasis>with<U></U>
>
> Can anyone help me in writing the match in Regex so that
> the tags are nested properly.
>
> I may have N number of emphasis tags nested in any combination.
>
> I will be very thankful if someone could help me.I'm trying this
> for the past one week.
>
> Thanks
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:986
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21

Reply via email to