in reply to conditional expression testing

hanabbsbbshana matches your RE, though. Are you sure you wanted to use (?(1)? 1 is always true, so the no-pattern after | is never considered, so your RE is equivalent to /(hana)(bbs)?\2\1$/