/* matchstar: leftmost longest search for c*re */
int matchstar(int c, char *re, char *text)
{
  char *t;

  for (t = text; *t != '\0' && (*t == c || c == '.'); t++)
     ;
  do {   /* * matches zero or more */
     if (matchhere(re, t))
        return 1;
  } while (t-- > text);
  return 0;
}

Example 6: A version of matchstar that does leftmost longest matching.

Back to Article
Copyright © 1999, Dr. Dobb's Journal