sds_wcmatch

int sds_wcmatch (const char *string, const char *match);


Determine whether this matches that.


This function checks to see if one string matches another string. It can be used to find an exact literal match, or by using any of the wildcard options listed below.

The argument string is the string to be tested.

The argument match is the string against which string is checked. This function is case-sensitive. The string match may contain any of the following special characters:

Character Description

` (reverse single-quote)

Forces sds_wcmatch to check against the next character exactly. Use this with any special characters if you want to disregard their special meanings and interpret them literally.

~ (tilde)

Causes sds_wcmatch to match anything that is not the same as matchthat. It must be the first character in the string. If you have a tilde at any other point in the string, sds_wcmatch looks to match it with a tilde.

*

The asterisk is an unlimited wildcard. Use it to match any character, or series of characters, at any place in matchthat.

?

The question mark works just like the asterisk, but for just one character at a time, as opposed to a series of characters.

# @

At, pound, and period are limited wildcards. They can be used to match single characters of specific types:

@ (at)

Any alphabetic character (A-Z)

- (hyphen)

Indicates a range of characters, such as sds_wcmatch(3-7).

, (comma)

You can use more than one pattern in matchthat. Just use the comma to separate the patterns. Sds_wcmatch looks for a match to any of the patterns (a OR b), but not necessarily all of them.

# (pound)

Any numeric character (0-9)

. (period)

Any non-alphanumeric character (&,%,+, etc.)

In addition to the above, the square brackets allow even greater flexibility:

This function returns RTNORM if the strings match, and RTERROR if they do not.

Example

The following example tries to match this string: char *doesthis = "1A2B3C";

sds_wcmatch(doesthis,"[CAT],[~DOG]");

This would return RTNORM because the string "1A2B3C" does include characters from the first set: C, A, or T. Since the comma works as an OR, sds_wcmatch would return RTNORM whether or not there was a match in the second pattern.

sds_wcmatch(doesthis,"1a2b3c");

This would return RTERROR because upper- and lower-case characters do not match.

sds_wcmatch(doesthis,"#@#@??");

This would return RTNORM because the string "1A2B3C" does match the pattern of numeric character, alpha character, followed by any other 4 characters.

Tell me about...

Programming Overview of SDS™ (Solutions Development System™)