pattern — C Library Procedures
NAME
Pattern_Match − Do csh-style pattern matching and more.
SYNOPSIS
#include <pattern.h>
int
Pattern_Match(pattern, name)
ARGUMENTS
char ∗pattern (in) Pattern to try matching.
char ∗name (in) Name to try matching against pattern.
DESCRIPTION
The Pattern_Match procedure provides pattern-matching capabilities for strings. It understands csh-style patterns, and logical and’s, or’s, and not’s with arbitrary levels of grouping. To use this procedure, pass it a string describing the pattern you are trying to match and a string to test against this pattern.
If the name argument successfully matches the pattern, the routine returns the value 0. If the pattern does not match, it returns 1. If an error occurs parsing the pattern, the routine returns -1.
Pattern_Match uses the following special characters: ∗ matches against any number of characters. ? matches against any single character. [] allows matching against a list of characters enclosed in the []’s, or against a range of characters as in [a-z]. \ allows turning off the magic properties of the special characters && requires a match against two patterns || allows a match against either of two patterns ! forbids a match against the following string () allows levels of grouping Examples:
"Alice" matches "A∗"
"d[efg]" matches "df"
"d[a-z]" matches "dq"
"f?ddle" matches "fiddle"
"f\?ddle" matches "f?ddle" but not "fiddle"
"x || y" matches "y"
"x∗ && ∗y" matches "xy" but not "frilly"
"(x∗ && ∗y) || (frilly) matches "xy" and also "frilly"
"!x∗ && ∗y" matches "frilly" but not "xy"
KEYWORDS
pattern, matching, string, compare
Sprite version 1.0 — May 03, 1991