The following regular expression will match "Saturday" or "Sunday" : (?:(Sat)ur|(Sun))day
But in one case backreference 1 is filled while backreference 2 is empty and in the other case vice-versa.
PHP (pcre) provides a nice operator "?|" that circumvents this problem. The previous regex would become (?|(Sat)ur|(Sun))day
. So there will not be empty backreferences.
Is there an equivalent in C# or some workaround ?