Esempio n. 1
0
 internal MatchCollection(Regex regex, string input, int length, int startat)
 {
     if ((startat < 0) || (startat > input.Length)) throw new ArgumentOutOfRangeException("startat");
     if (length < 0) length = input.Length;
     this._regex = regex;
     this._input = input;
     this._lastIndex = length;
     this._startIndex = startat;
     this._previousIndex = 0;
     this._matches = new ArrayList();
 }
Esempio n. 2
0
 internal Match(Regex regex, int capcount, string text, int begpos, int len, int startpos)
     : base(text, new int[2], 0)
 {
     this._regex = regex;
     this._matchcount = new int[capcount];
     this._matches = new int[capcount][];
     this._matches[0] = base._caps;
     this._textbeg = begpos;
     this._textend = begpos + len;
     this._textstart = startpos;
     this._balancing = false;
 }
Esempio n. 3
0
 internal virtual void Reset(Regex regex, string text, int textbeg, int textend, int textstart)
 {
     this._regex = regex;
     base._text = text;
     this._textbeg = textbeg;
     this._textend = textend;
     this._textstart = textstart;
     for (int i = 0, e = this._matchcount.Length; i < e; ++i) this._matchcount[i] = 0;
     this._balancing = false;
 }
Esempio n. 4
0
        /// <summary>
        /// Splits the input string at the positions defined by a specified regular expression pattern. Specified options modify the matching operation.
        /// </summary>
        /// <param name="regex">The Regex to use to Split the input string</param>
        /// <param name="input">The input string</param>
        /// <param name="count">The amount of Splits to perform</param>
        /// <param name="startat">The start index in the input</param>
        /// <returns>The result of splitting the input string against the Regexp</returns>
        public static string[] Split(Regex regex, string input, int count, int startat)
        {
            ///Sanity checks
            if (count < 0) throw new ArgumentOutOfRangeException("count");
            if (startat < 0 || startat > input.Length) throw new ArgumentOutOfRangeException("startat");
            //The result of splitting a string is... the String
            if (count == 1) return new string[] { input };
            //Get a match, if it's not successful then return the split which is the input
            Match match = regex.Match(input, startat);
            if (!match.Success) return new string[] { input };
            //Make an array 1 less then count because count is not zero based
            string[] resultsTemp = new string[--count];
            //Current count
            int current = 0;
            //if(regex.RightToLeft) Reverse String basically or just do this in reverse by doing math on startAt and inputLength
            int startIndex = 0;
            AddMatch:
            //Add the match
            resultsTemp[current] = input.Substring(startIndex, match.Index - startIndex);
            //Increment the count
            ++current;
            //Move the index
            startIndex = match.Index + match.Length;
            //Add any subsequent matches in the group
            for (int i = 1; i < match.Groups.Count; ++i) if (match.IsMatched(i))
                {
                    //Set the value of the result
                    resultsTemp[current] = match.Groups[i].ToString();
                    //Increment the count
                    ++current;
                }

            //If there can still be a match
            if (--count != 0)
            {
                //See if we can match it
                match = match.NextMatch();
                //If the match is successful do everything again
                if (match.Success) goto AddMatch;
            }
            //Add the final match and increment the count
            resultsTemp[current++] = input.Substring(startIndex, input.Length - startIndex);
            //Get the real results from the temporary array
            string[] results;
            if (current == count) return resultsTemp;
            results = new string[current];
            Array.Copy(resultsTemp, 0, results, 0, current);
            //return them
            return results;
        }
Esempio n. 5
0
 /// <summary>
 /// Scans a Regex to find a Match using Full Fx Matching Style
 /// </summary>
 /// <param name="regex"></param>
 /// <param name="text"></param>
 /// <param name="textbeg"></param>
 /// <param name="textend"></param>
 /// <param name="textstart"></param>
 /// <param name="prevlen"></param>
 /// <param name="quick"></param>
 /// <returns></returns>
 internal Match Scan(Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick)
 {
     //bool flag = false;
     Regex runregex = regex;
     string runtext = text;
     int runtextbeg = textstart;
     int runtextend = textend;
     int runtextstart = textstart;
     int runtextpos = textstart;
     int num = 1; //runregex.RightToLeft ? -1 : 1;
     int num2 = runtextend; // runregex.RightToLeft ? runtextbeg: runtextend;
     if (prevlen == 0)
     {
         if (runtextpos == num2)
         {
             return MFE.RegularExpressions.Match.Empty;
         }
         runtextpos += num;
     }
     Match runmatch = MFE.RegularExpressions.Match.Empty;
     return runmatch;
     //while (true)
     //{
     //    if (this.FindFirstChar())
     //    {
     //        if (!flag)
     //        {
     //            this.InitMatch();
     //            flag = true;
     //        }
     //        this.Go();
     //        if (runmatch._matchcount[0] > 0)
     //        {
     //            return runmatch.TidyMatch(quick);
     //        }
     //        runtrackpos = this.runtrack.Length;
     //        runstackpos = this.runstack.Length;
     //        runcrawlpos = this.runcrawl.Length;
     //    }
     //    if (this.runtextpos == num2)
     //    {
     //        this.TidyMatch(quick);
     //        return Match.Empty;
     //    }
     //    this.runtextpos += num;
     //}
 }