Beispiel #1
0
RegEx::~RegEx()
{
   ClearMatchList();
   delete ovector;
   if (pe)
      pcre_free(pe);
   pcre_free(re);
}
Beispiel #2
0
bool RegEx::Search(const char * subject, int len, int options)
{
  ClearMatchList();

  subjectStr  = subject;
  lastStart   = 0;
  subjectLen  = (len >= 0) ? len : strlen(subject);
  lastMatches = pcre_exec(re, pe, subjectStr, subjectLen, 0, options, ovector, 3*substrcount);

  return lastMatches > 0;
}
Beispiel #3
0
RegEx::~RegEx()
{
  ClearMatchList();
  if (ovector != NULL)
  {
     delete [] ovector;
  }
  if (pe)
  {
     if (allocated_study && study_size)
     {
        pcre_free(pe->study_data);
     }
     pcre_free(pe);
  }
  pcre_free(re);
}
Beispiel #4
0
bool RegEx::SearchAt(const char* subject,  ///< the string to be searched for a match
                     int offset,           ///< offset to begin search in subject string
                     int len,              ///< offset to begin search in subject string
                     int options           ///< sum of any PCRE options flags
                     )
{
   /*
    * Search the subject string for matches to this regular expression
    *    @returns true if a match is found.
    */
   ClearMatchList();

   subjectStr  = subject;
   lastStart   = 0;
   subjectLen  = (len >= 0) ? len : strlen(subject);
   lastMatches = pcre_exec(re, pe, subject, subjectLen, offset, options, ovector, 3*substrcount);

   return lastMatches > 0;
}
Beispiel #5
0
bool RegEx::SearchAgain(int options)
{
  ClearMatchList();
  bool matched;
  lastStart = ovector[1];
  if (lastStart < subjectLen)
  {
     lastMatches = pcre_exec(re, pe, subjectStr, subjectLen, lastStart, options,
                             ovector, 3*substrcount);
     matched = lastMatches > 0;
  }
  else
  {
     // The last search matched the entire subject string
     // If the pattern allows a null string to match, then another call to pcre_exec
     // would return that match, so don't do that.
     // Instead, return no match to prevent an infinite loop.
     matched = false; 
  }
  return matched;
}
Beispiel #6
0
bool RegEx::SearchAgain(int options)
{
   ClearMatchList();
   return pcre_exec(re, pe, lastsubject, slen, ovector[1], options, ovector, 3*substrcount) > 0;
}
Beispiel #7
0
bool RegEx::Search(const char * subject, int len, int options)
{
   ClearMatchList();
   return pcre_exec(re, pe, lastsubject = subject, slen = (len >= 0) ? len : strlen(subject), 0, options, ovector, 3*substrcount) > 0;
}