It's sometimes easier to first replace some things with single characters that are not used anywhere else (¬ and | are likely), and then do further regex work with them, because negative patterns are easier with single characters.
For instance, if you first replace every <i> with ¬ and every </i> with |, you can now find nested italics markup with "¬[^|]*¬".
|