SpiceBoolean matchw_c ( ConstSpiceChar * string,
ConstSpiceChar * templ,
SpiceChar wstr,
SpiceChar wchr )
Determine whether a string is matched by a template containing
wild cards.
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.
matchw_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"
.
.
.
matchw_c ( "ALCATRAZ", "A*Z", '*', '%' );
matchw_c ( " ALCATRAZ ", "a*z", '*', '%' );
matchw_c ( "alcatraz", " A*Z ", '*', '%' );
matchw_c ( " ALCATRAZ ", " A*Z ", '*', '%' );
matchw_c is case-sensitive: uppercase characters do not match
lowercase characters, and vice versa. Wild characters match
characters of both cases.
Let
string = " ABCDEFGHIJKLMNOPQRSTUVWXYZ "
wstr = '*'
wchr = '%'
Then
if TEMPL is "*A*" matchw_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
"*bcd*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 matchw_c source file matchw_c.c
|