SpiceBoolean matchi_c ( ConstSpiceChar * string,
ConstSpiceChar * templ,
SpiceChar wstr,
SpiceChar wchr )
Determine whether a string is matched by a template containing
wild cards. The pattern comparison is case-insensitive.
None.
CHARACTER, COMPARE
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
string I String to be tested.
templ I Template (with wild cards) to test against string.
wstr I Wild string token.
wchr I Wild character token.
The function returns the value SPICETRUE if string matches templ,
SPICEFALSE if not.
string is the input character string to be tested for
a match against the input template. Leading and
trailing blanks are ignored.
templ is the input template to be tested for a match
against the input string. TEMPL may contain wild
cards. Leading and trailing blanks are ignored.
wstr is the wild string token used in the input template.
The wild string token may represent from zero to
any number of characters.
wchr is the wild character token used in the input
template. The wild character token represents
exactly one character.
The function returns SPICETRUE when the input string matches the
input template, and SPICEFALSE otherwise. The string and template
match whenever the template can expand (through replacement of its
wild cards) to become the input string.
None.
1) If either the input string pointer is null, the error
SPICE(NULLPOINTER) will be signaled. The function will
return SPICEFALSE.
2) If either input string has length zero, the error
SPICE(EMPTYSTRING) will be signaled. The function will
return SPICEFALSE.
None.
matchi_c ignores leading and trailing blanks in both the string
and the template. All of the following are equivalent: they
all return SPICETRUE.
#include "SpiceUsr.h"
.
.
.
matchi_c ( "ALCATRAZ", "A*Z", '*', '%' );
matchi_c ( " ALCATRAZ ", "a*z", '*', '%' );
matchi_c ( "alcatraz", " A*Z ", '*', '%' );
matchi_c ( " ALCATRAZ ", " A*Z ", '*', '%' );
matchi_c is case-insensitive: uppercase characters match
lowercase characters, and vice versa. Wild characters match
characters of both cases.
Let
string = " ABCDEFGHIJKLMNOPQRSTUVWXYZ "
wstr = '*'
wchr = '%'
Then
if TEMPL is "*A*" matchi_c is SPICETRUE
"A%D*" SPICEFALSE
"A%C*" SPICETRUE
"%A*" SPICEFALSE
"%%CD*Z" SPICETRUE
"%%CD" SPICEFALSE
"A*MN*Y*Z" SPICETRUE
"A*MN*Y*%Z" SPICEFALSE
"*BCD*Z*" SPICETRUE
"*bdc*z*" SPICEFALSE
" *bcD*Z* " SPICETRUE
None.
None.
N.J. Bachman (JPL)
W.L. Taber (JPL)
I.M. Underwood (JPL)
-CSPICE Version 1.0.0, 17-AUG-1999 (NJB) (WLT) (IMU)
match string against wildcard template
test whether a string matches a wildcard template
Link to routine matchi_c source file matchi_c.c
|