Created
April 19, 2012 08:37
-
-
Save cpylua/2419704 to your computer and use it in GitHub Desktop.
Here is a quick little wildcard matcher by Arjan Kenter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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