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.


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!
Last Updated: 9/23/96 Joe Strout ( )