Pchp.Library.PerlRegex.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
        /// <summary>
        /// Initializes all the data members that are used by Go()
        /// </summary>
        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;
        }