Reputation: 15
Wanna exclude the specific line "//2" from choose item. <%-- //1 --%>
<%-- //1
//1 --%>
<%-- //1
//1
//1 --%>
//2
<%-- //1 --%>
<%-- //1 //1 --%>
//3
By JavaScript, Here is the regex: (?<=<%-{2}[\w\W]*?)\/\/(?=[\w\W]*?-{2}%>)
I found many ways but didn't work out. Could somebody have a good idea to fix it?
Upvotes: 0
Views: 32
Reputation: 163287
You could match the opening <%--
and then match until you encounter //
without matching either <%--
or --%>
Then do the same after matching //
again.
In Javascript, instead of using [\w\W]
you can also use [^]
.
(?<=<%--(?:(?!<%--|--%>)[^])*)\/\/(?=(?:(?!<%--|--%>)[^])*--%>)
Upvotes: 1