You can match what is inside the DIV tag using this regex that features a non-fixed width look-behind (thanks to .NET regex engine):
(?s)(?<=<div\s[^>]*?class=["']?important-contents["']?[^>]*?>).*?(?=</div>)
Then, to remove all tags, you can use this regex to remove all tags inside the matched DIV contents:
</?[^>]+>
To remove <script>
tags that may find their way to the DIV tag, let's introduce another step:
(?s)<script[^>]*?>.*?</script>
I do not know of a way to match discontinuous texts, so it can only be done in {2,} steps.
DISCLAIMER: if you have "malformed" HTML, you can get wierd results, or no match at all.
Sample code:
var div_rgx = new Regex(@"(?si)(?<=<div\s[^>]*?class=[""']?important-contents[""']?[^>]*?>).*?(?=</div>)");
var tag_rgx = new Regex(@"</?[^>]+>");
var script_rgx = new Regex(@"(?s)<script[^>]*?>.*?</script>");
var txt = "<html>\r\n<body>\r\n<div class='important-contents'>\r\n<script>function getV(str) { return 0; }</script>\r\n<span>My <i>text</i><font face=\"Verdana\">.</font></span>\r\n</div>\r\n</body>\r\n</html>";
var result = div_rgx.Match(txt);
if (result.Success)
var final = tag_rgx.Replace(script_rgx.Replace(result.Value, string.Empty), string.Empty).Trim();
Output:
