| matchw_c |
|
Table of contents
Procedure
matchw_c ( Match string against wildcard template )
SpiceBoolean matchw_c ( ConstSpiceChar * string,
ConstSpiceChar * templ,
SpiceChar wstr,
SpiceChar wchr )
AbstractDetermine whether a string is matched by a template containing wild cards. The comparison is case-sensitive. Required_ReadingNone. KeywordsCHARACTER COMPARE Brief_I/OVARIABLE 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. Detailed_Input
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.
Detailed_OutputThe 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. ParametersNone. Exceptions
1) If any of the `string' or `templ' input string pointers is
null, the error SPICE(NULLPOINTER) is signaled. The function
returns the value SPICEFALSE.
2) If any of the `string' or `templ' input strings has zero
length, the error SPICE(EMPTYSTRING) is signaled. The function
returns the value SPICEFALSE.
FilesNone. Particulars
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.
Examples
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
RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.L. Taber (JPL) I.M. Underwood (JPL) Version
-CSPICE Version 1.0.1, 04-AUG-2021 (NJB) (JDR)
Edited the header to comply with NAIF standard.
Corrected header example to show case-sensitive comparison.
-CSPICE Version 1.0.0, 17-AUG-1999 (NJB) (WLT) (IMU)
Index_Entriesmatch string against wildcard template test whether a string matches a wildcard template |
Fri Dec 31 18:41:09 2021