System.Text.RegularExpressions.Match.Reset C# (CSharp) Method

Reset() private method

private Reset ( Regex regex, string text, int textbeg, int textend, int textstart ) : void
regex Regex
text string
textbeg int
textend int
textstart int
return void
        internal virtual void Reset(Regex regex, string text, int textbeg, int textend, int textstart)
        {
            _regex = regex;
            _text = text;
            _textbeg = textbeg;
            _textend = textend;
            _textstart = textstart;

            for (int i = 0; i < _matchcount.Length; i++)
            {
                _matchcount[i] = 0;
            }

            _balancing = false;
        }

Usage Example

Example #1
0
        /*
         * Initializes all the data members that are used by Go()
         */
        private void InitMatch()
        {
            // Use a hashtable'ed Match object if the capture numbers are sparse

            if (_runmatch == null)
            {
                if (_runregex._caps != null)
                {
                    _runmatch = new MatchSparse(_runregex, _runregex._caps, _runregex._capsize, _runtext, _runtextbeg, _runtextend - _runtextbeg, _runtextstart);
                }
                else
                {
                    _runmatch = new Match(_runregex, _runregex._capsize, _runtext, _runtextbeg, _runtextend - _runtextbeg, _runtextstart);
                }
            }
            else
            {
                _runmatch.Reset(_runregex, _runtext, _runtextbeg, _runtextend, _runtextstart);
            }

            // note we test runcrawl, because it is the last one to be allocated
            // If there is an alloc failure in the middle of the three allocations,
            // we may still return to reuse this instance, and we want to behave
            // as if the allocations didn't occur. (we used to test _trackcount != 0)

            if (_runcrawl != null)
            {
                _runtrackpos = _runtrack.Length;
                _runstackpos = _runstack.Length;
                _runcrawlpos = _runcrawl.Length;
                return;
            }

            InitTrackCount();

            int tracksize = _runtrackcount * 8;
            int stacksize = _runtrackcount * 8;

            if (tracksize < 32)
            {
                tracksize = 32;
            }
            if (stacksize < 16)
            {
                stacksize = 16;
            }

            _runtrack    = new int[tracksize];
            _runtrackpos = tracksize;

            _runstack    = new int[stacksize];
            _runstackpos = stacksize;

            _runcrawl    = new int[32];
            _runcrawlpos = 32;
        }
All Usage Examples Of System.Text.RegularExpressions.Match::Reset