Skip if the two sequences to the right have different shapes: ععع ععع.
Test passes if the three Arabic characters don't join, or styling is applied to the glyph corresponding to the middle letter, or the styling is applied to the whole ligature.

علا