/// <summary> /// evaluate if this pattern matches the current location in the string. /// </summary> /// <param name="InString"></param> /// <param name="InBx"></param> /// <param name="InEx"></param> /// <param name="InIx"></param> /// <returns></returns> public bool Evaluate(string Text, int Bx, int Ex, int Ix) { if (mLeadChar == Text[Ix]) { return(true); } else { bool rv = Stringer.CompareSubstringEqual( Text, Ix, Ex, this.PatternValue); return(rv); } }
/// <summary> /// Find the pattern that matches the substring at the spcfd position /// in the string. /// </summary> /// <param name="InString"></param> /// <param name="InStringIx"></param> /// <param name="InStringEx"></param> /// <returns></returns> public ScanPattern FindPatternAtSubstring( string InString, int InStringIx, int InStringEx) { ScanPattern foundPat = null; char ch1 = InString[InStringIx]; // find first pattern that matches lead char of the substring. int patIx = Array.IndexOf <char>(this.LeadChars, ch1); if (patIx >= 0) { ScanPattern pat = this.ScanPatternsArray[patIx]; while (pat != null) { // bool rv = ScanPattern.Evaluate( bool rv = Stringer.CompareSubstringEqual( InString, InStringIx, InStringEx, pat.PatternValue); if (rv == true) { if (foundPat == null) { foundPat = pat; } // Matching pattern already found, but this pattern also matches and it is // longer. Always return the longer pattern. else if (pat.PatternValue.Length > foundPat.PatternValue.Length) { foundPat = pat; } } pat = pat.NextSameLeadChar; } } return(foundPat); }