I don't have a C# compiler to test it with, but give this a try:

while (Regex.IsMatch(htmltags, "<Emphasis type=\"([a-z]+)\">",
RegexOptions.IgnoreCase))
{
        htmltags = Regex.Replace(htmltags, "<Emphasis
type=\"([a-z]+)\">(([^<]|<(?!Emphasis))+?)</Emphasis>", "<$1>$2</$1>",
RegexOptions.IgnoreCase);
}


On 11/15/06, mira mira <[EMAIL PROTECTED]> wrote:
> xml
> ***
> <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>
>
> can u please get me the example using c#
>
> my sample code in c#
> ********************
> if(Regex.IsMatch(htmltags,"(<Emphasis 
> Type=\"Bold\">(.+?)</Emphasis>)",RegexOptions.IgnoreCase))
> {
> htmltags =Regex.Replace(htmltags,"<Emphasis 
> Type=\"Bold\">(.+?)</Emphasis>","<Bold>$1</Bold>",RegexOptions.IgnoreCase);
> }
>
> where html is  a string which holds the xml values.
> I'm writing the replacement tag with regex.
> But according to my match if it has n no of emphasis tags nested i will face 
> problems.
>
> I will be very thankful if u give me a solution and a sample code to overcome
> the problem.
>
> Thanks
>
>
>
>
> >>> 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. <<
> >
> >That's why I said with the appropriate loop.
> >
> >My example in the next message works with the code you provided, and I
> >can't think of any situations why it shouldn't work, so hopefully it
> >helps make sense of whatever I was saying last night. :)
> >
> >
> >On 11/14/06, Rob Wilkerson <[EMAIL PROTECTED]> wrote:
> >>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:996
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