Skip to content

Instantly share code, notes, and snippets.

@cpylua
Created April 19, 2012 08:37
Show Gist options
  • Save cpylua/2419704 to your computer and use it in GitHub Desktop.
Save cpylua/2419704 to your computer and use it in GitHub Desktop.
Here is a quick little wildcard matcher by Arjan Kenter
/* Here is a quick little wildcard matcher by Arjan Kenter: */
int match(char *pat, char *str)
{
switch(*pat) {
case '\0': return !*str;
case '*': return match(pat+1, str) ||
*str && match(pat, str+1);
case '?': return *str && match(pat+1, str+1);
default: return *pat == *str && match(pat+1, str+1);
}
}
/* (Copyright 1995, Arjan Kenter) */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment