How to convert all the tags in a string to uppercase?

Posted on 2006-04-20
Last Modified: 2010-04-01
one more question today..

How to convert all the tags in a string to uppercase except the URL in the <A> tag? A code example would be great.

string content = "<BR><br><h1>H1 text</H1> <BR> <H2>H2 text</H2><BR><H3>H2 text</H3><BR><B>Bold text</B><BR><I>italic text</I><BR><H3>Dette er en test med h3. Jepp!</H3> <BR> <A href=\"\">Linkname</A><BR><BR>";
Question by:m-jansen
    1 Comment
    LVL 22

    Accepted Solution

    Its pretty hard--   you need a full-blown HTML parser to tell apart things that look like tags but are actually comments or embedded in php or javascript.

    for example it's perfectly legal to have a javascript string    foo  = 'A valid hyperlink looks like: <A href="">';


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
    What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now