tags:

views:

78

answers:

2

I would require a RegEx in .NET in such a way that to remove the commented lines in HTML page/code where ever the tag finds as commented portion or code.

For reference:

<!--loop output-------end-->

I want to remove the portion of commented code/line as above using RegEx.

Provide me a RegEx for the same.

A: 

For the code like javascript in HTML page, I suggest you to use YUI Compressor

For HTML, if you using .NET to generate HTML, you can just don't print out <!-- --> and // parts, isn't it?

Regexes are not very effective for that case.

Because, lets say, you put //.*\n to clear up comment lines, but in following XHTML, if you remove //<![CDATA[ and //]]> , XHTML become broken.

<script type="text/javascript">
//<![CDATA[
alert("<This is compatible with XHTML>");
//]]>
</script>
S.Mark
A: 

How about

str = str.ReplaceAll('<!--loop output-------end-->', '');
Peter Stuifzand