jeudi 5 mars 2015

How to catch if-statement block and name block in regular expressions

How to capture if-statement block. I've capture the else-statement block in a named Group. My current solution is at this permalink: http://ift.tt/1M8MKyq



@if\([^)]*\)\s*{(((?>(?<open>@if\([^)]*\)\s*{)|@{[^}]*}|[^}@]+|(?:}else{(?<else>([^}]*))(?=}endif@))|(?<-open>}endif@)))*(?(open)(?!)))}endif@


Content inside statement block are html related. I.e.



@if(prevbutton.visible=='True'){
<div style="float:left; display:inline; margin-right: 5px; padding-top:7px;">
<span class="arrows_prev" id="prevbottom" title="@{prevbutton.toindex}" rel="prev" data-page-number="@{prevbutton.toindex}"></span>
</div>
}else{
test
}endif@

Aucun commentaire:

Enregistrer un commentaire