Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Regex to strip everything except <h3>, <h4> and <h5> tags and the text within them

  •  11-30-2007, 1:12 PM

    Regex to strip everything except <h3>, <h4> and <h5> tags and the text within them

    Hi,

     I was looking for a regex which would strip all HTML and included text except what is included in <h3>,<h4> and <h5> tags.

    I am planning to use this regex in javascript. 

     
    example:

     
    Input:

    <ul>
          <li><h4>Sub Menu</h4>
              <ul>
                  <li><a href="http://regexadvice.com/forums/AddPost.aspx?ForumID=68#">Sub-Sub Menu</a></li>
                  <li><a href="http://regexadvice.com/forums/AddPost.aspx?ForumID=68#">Sub-Sub Menu</a></li>
                  <li><a href="http://regexadvice.com/forums/AddPost.aspx?ForumID=68#">Sub-Sub Menu</a></li>
                  
                  <li><h5>Sub-Sub Menu</h5>
                      <ul>
                          <li><a href="http://regexadvice.com/forums/AddPost.aspx?ForumID=68#">Sub-Sub-Sub Menu</a></li>
                          <li><a href="http://regexadvice.com/forums/AddPost.aspx?ForumID=68#">Sub-Sub-Sub Menu</a></li>
                          <li><a href="http://regexadvice.com/forums/AddPost.aspx?ForumID=68#">Sub-Sub-Sub Menu</a></li>
                      </ul>
                    </li>
              </ul>
          </li>
        </ul>

    Output: <h4>Sub Menu</h4><h5>Sub-Sub Menu</h5>

     

    Please help 

    - Pritesh
     

View Complete Thread