Beispiel #1
0
        /// <summary>
        /// run and don't return until its done
        /// </summary>
        /// <param name="TargetString"></param>
        /// <returns></returns>
        public List <Match> RunCheck(string TargetString)
        {
            List <Match> ret = new List <Match>();
            int          step_start, step_end;
            Match        Result;

            Regex[] SafeDup = new Regex[CompiledEntries.Count];
            CompiledEntries.CopyTo(SafeDup);
            bool First = true;

            foreach (Regex Code in SafeDup)
            {
                step_start = 0;
                step_end   = TargetString.Length;
                First      = true;
                while (true)
                {
                    var Results = Code.Matches(TargetString, step_start);
                    if (Results.Count > 0)
                    {
                        var MatchArray = new Match[Results.Count];
                        Results.CopyTo(MatchArray, 0);
                        ret.AddRange(MatchArray);
                        step_start = Results[Results.Count - 1].Index + 1;
                    }
                    else
                    {
                        break;
                    }

                    /*
                     * var result = Code.Match(TargetString, step_start);
                     * if (result.Success)
                     * {
                     *  ret.Add(result);
                     *  step_start = result.Index+1;
                     *  if (step_start> TargetString.Length)
                     *  {
                     *      break;
                     *  }
                     * }
                     * else
                     * {
                     *  break;
                     * }
                     */
                }
            }
            return(ret);
        }
Beispiel #2
0
 /// <summary>
 /// compile the collected syntax
 /// </summary>
 public void Compile()
 {
     if (Ready == false)
     {
         RegexOptions BuildOptions = RegexOptions.Compiled;
         if (!CaseSensitive)
         {
             BuildOptions |= RegexOptions.IgnoreCase;
         }
         foreach (string word in Syntax.Keys)
         {
             Regex Entry = new Regex(MakePattern(word), BuildOptions);
             CompiledEntries.Add(Entry);
         }
         Ready = true;
     }
 }
Beispiel #3
0
 public void Clear()
 {
     CompiledEntries.Clear();
     Ready = false;
     Syntax.Clear();
 }