Hayat Hayat - 3 months ago 15
C# Question

Regex For Finding ASP.Net page multiline comment

enter image description hereI have Following code. In Visual studio it possible to find using regex and replace. so i am not able to generate regex for this code. Can anyone help me ?

<div class="span2 control-group">
<%--<asp:Label ID="lblTeamName" Text="Team" runat="server" CssClass="control-label bold"></asp:Label>--%>
<div class="controls">
<%--<telerik:RadComboBox ID="rcbTeam" EmptyMessage="Select" runat="server" Width="160px"
OnSelectedIndexChanged="rcbTeam_SelectedIndexChanged" AutoPostBack="true">
</telerik:RadComboBox>--%>
<asp:RequiredFieldValidator ID="RF2" runat="server" ErrorMessage="*" Display="Dynamic" Font-Size="X-Large"
SetFocusOnError="True" ValidationGroup="ChartValidate1" ForeColor="red" ControlToValidate="rcbTeam"></asp:RequiredFieldValidator>
</div>
</div>


Regex needed for finding content in between of <%--content--%>

Answer

Here is a regex you can use (please note the use of *? lazy quantifier so as not to overmatch):

<%--[\r\n\s\S]*?--%>

Tested in Visual Studio 2012:

enter image description here