The (?(name).. alternation uses the Success property of the group to determine if it as a match. This may include matches that contain no data.
Consider the following expression to identify the area code part of a phone number. Say you want to match either (nnn) or nnn- . You might try the following:
(?<agroup>\(?)\d{3}(?(agroup)\)|-)
But this will always match the right paren because the term \(? will always be successful (matching either one left paren, or no left parens).
What you really want is the following:
(?<agroup>\()?d{3}(?(agroup)\)|-)
In this case if a left paren isn't found, the group will not contain a succesful match.
In both cases, a missing left paren will result in an empty group, but in the first case it will count as a successful match and thus the "true" term of the alternation will apply, in the second case it will count as a failed match and thus the "false" term of the alternation will apply.