Example #1
0
 public void FindTokenPair(string theFirstToken, string theSecondToken, TokenBodyFilter theFilter) {
     Leader = Substring.Empty;
     Body = Substring.Empty;
     if (myPrevious >= myInput.Length) return;
     int first, second = 0;
     for (first = myPrevious; first < myInput.Length; first = second + theSecondToken.Length) {
         first = Find(myInput, theFirstToken, first);
         second = Find(myInput, theSecondToken, first + theFirstToken.Length + 1);
         if (second == myInput.Length) {
             first = second;
             break;
         }
         int body = first + theFirstToken.Length;
         if (second <= body) continue;
         Body = new Substring(myInput, body, second - body);
         if (theFilter(Body)) break;
     }
     if (first > myPrevious) {
         Leader = new Substring(myInput, myPrevious, first - myPrevious);
     }
     myPrevious = second + theSecondToken.Length;
 }
Example #2
0
        public void FindTokenPair(string theFirstToken, string theSecondToken, TokenBodyFilter theFilter)
        {
            Leader  = Substring.Empty;
            Body    = Substring.Empty;
            Element = Substring.Empty;
            if (myPrevious >= myInput.Length)
            {
                return;
            }
            int first, second = 0;

            for (first = myPrevious; first < myInput.Length; first = second + theSecondToken.Length)
            {
                first  = Find(myInput, theFirstToken, first);
                second = Find(myInput, theSecondToken, first + theFirstToken.Length + 1);
                if (second == myInput.Length)
                {
                    first = second;
                    break;
                }
                int body = first + theFirstToken.Length;
                if (second <= body)
                {
                    continue;
                }
                Body    = new Substring(myInput, body, second - body);
                Element = new Substring(myInput, first, second - first + theSecondToken.Length);
                if (theFilter(Body))
                {
                    break;
                }
            }
            if (first > myPrevious)
            {
                Leader = new Substring(myInput, myPrevious, first - myPrevious);
            }
            myPrevious = second + theSecondToken.Length;
        }