MatchWild

by Joe Strout

MatchWild is not a class; instead, it is a simple module containing four functions:

In these functions, all parameters are character pointers (const where appropriate) except n, which is the length of a buffer to hold the result of a replace operation. (It's OK for this buffer to be the same as one of the source strings.)

The only currently supported wildcard is the asterisk, which matches zero or more characters.


Examples

MatchWild( "this is a test", "this*") returns 1
MatchWild( "is this a test", "this*") returns 0
MatchWild( "is this a test", "*this*") returns 1
char d[80]; ReplaceWild(d,80, "*that*") stuffs "is that a test" into d (assuming previous call above)
MatchReplaceWild(d,80,"is this a test","*is*","*was*") stuffs "was this a test" into d and returns 1

Here's the code...

Share and enjoy!

http://www-ncmir.ucsd.edu/~jstrout/classlib/MatchWild.html
Last Updated: 9/23/96 Joe Strout ( joe@strout.net )