I have a regular expression that breaks html into necessary for me peaces. I will not present the whole regex, because it's too long. In a nutshell, its a multi-line table cells row-by-row parser. Recently i've ran into a trouble: the layout of parsing pages has changed, so I started remastering the regex to fit new layout, but I've found that layout wrapping data I need in a particular cell in some rows may differ.
What do we have?
The layout of the cell may be like this or like this
which leads me to question: how do I capture needed data and do not have additional unnecessary group?
Conditions in regexps described here regular-expressions.info/conditional.html, I've read it but still don't have a clue.