Figure 2: Code segment of modified Boyer-Moore algorithm

for (j=i=endMatch?textLen-1:creLength-1; j>=0; i--,j--)
{
   while (!MatchChar(text[i],j))
   {
      //It did not match so let's increment our text index
      // by the skip distance
      i+=(creLength-j > skip[text[i]]) ? 
          creLength-j : skip[text[i]] ;
       
      // Set j to last char in pattern
      j = creLength-1;

      // If we index past the end of the text then no match
      // If the match must be at the beginning of the buffer
      // and i is greater than the start of text plus the pattern
      // length, then there is no match
      if (i >= textLen || (beginMatch==true && i-j>lead)) 
         return NULL;
   }
}