So, let's simplify it like this
(<)?[^%>]++(?(1)>)%
It's the same but I put posessive quantifier ++, instead of +
Apply this to
<didi%
The regexp engine do this:
- first it tries for "<", will match
- then will match "didi"
- then, cause it find the first "<" will try to match ">", but it fails, so the engine backtrack again to the first "<", now because it's optional, the "<" will be matched by [^%>]+ part, so the conditional part (?(1)>) will not match (it will skip that part because first group, B in your case, isn't match after backtracking)
- then will match %
http://portal-vreme.ro