Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 
Remove content between HEAD tags using Regex and c# (08 December 2008)


 
To remove all content between HEAD-tags from a webpage using Regex and C# use the following code snippet:
        private string RemoveContentBetweenHeadTags(string in_HTML)
        {
            string lv_HTML = in_HTML;

            lv_HTML = Regex.Replace(lv_HTML, "<head.*?</head>", ""
                      , RegexOptions.Singleline  RegexOptions.IgnoreCase);
              
            return lv_HTML;
        }

Posted by Xander Zelders



0 Comments:

Post a Comment

<< Home

 
Previous Posts
    - Strip HTML tags, HEAD content and SCRIPT tags from...
    - 9 Tips for creating indexes in SQL Server
    - Performance Tip 1: Avoid non-sargable WHERE-clause...
    - 23 Tips to improve the performance of your SQL que...
    - A cheat sheet for SQL Server developers
    - How to replace certain word with a hyperlink using...
    - How to Highlight a specific word in HTML content (...
    - how to extract SRC from IMG elements in HTML code
    - How to extract URL and Anchor from HTML content
    - Grab the content of a (GZIP) webpage using C#



Disclaimer & Terms of Use | DotNet4All.Com concept & © 2004 - 2007 by Zelders² - Holland