System.Text.RegularExpressions.RegexRunner.TransferCapture C# (CSharp) Method

TransferCapture() protected method

Called by Go() to capture a subexpression. Note that the capnum used here has already been mapped to a non-sparse index (by the code generator RegexWriter).
protected TransferCapture ( int capnum, int uncapnum, int start, int end ) : void
capnum int
uncapnum int
start int
end int
return void
        protected void TransferCapture(int capnum, int uncapnum, int start, int end)
        {
            int start2;
            int end2;

            // these are the two intervals that are cancelling each other

            if (end < start)
            {
                int T;

                T = end;
                end = start;
                start = T;
            }

            start2 = MatchIndex(uncapnum);
            end2 = start2 + MatchLength(uncapnum);

            // The new capture gets the innermost defined interval

            if (start >= end2)
            {
                end = start;
                start = end2;
            }
            else if (end <= start2)
            {
                start = start2;
            }
            else
            {
                if (end > end2)
                    end = end2;
                if (start2 > start)
                    start = start2;
            }

            Crawl(uncapnum);
            runmatch.BalanceMatch(uncapnum);

            if (capnum != -1)
            {
                Crawl(capnum);
                runmatch.AddMatch(capnum, start, end - start);
            }
        }