wildcard.icn: Procedures for UNIX-like wild-card pattern matching

link wildcard
September 26, 1990; Robert J. Alexander
This file is in the public domain.

This is a kit of procedures to deal with UNIX-like filename wild-card
patterns containing *, ?, and [...].  The meanings are as of the
pattern characters are the same as in the UNIX shells csh and sh.
They are described briefly in the wild_pat() procedure.

These procedures are interesting partly because of the "recursive
suspension" technique used to simulate conjunction of an arbitrary
number of computed expressions.


The public procedures are:

wild_match(pattern,s,i1,i2) : i3,i4,...,iN
wild_find(pattern,s,i1,i2) : i3,i4,...,iN

wild_match() produces the sequence of positions in "s" past a
substring starting at "i1" that matches "pattern", but fails if there
is no such position.  Similar to match(), but is capable of
generating multiple positions.

wild_find() produces the sequence of positions in "s" where
substrings begin that match "pattern", but fails if there is no such
position.  Similar to find().

"pattern" can be either a string or a pattern list -- see wild_pat(),
below.

Default values of s, i1, and i2 are the same as for Icon's built-in
string scanning procedures such as match().


wild_pat(s) : L

Creates a pattern element list from pattern string "s".  A pattern
element is needed by wild_match() and wild_find().  wild_match() and
wild_find() will automatically convert a pattern string to a pattern
list, but it is faster to do the conversion explicitly if multiple
operations are done using the same pattern.

Source code | Program Library Page | Icon Home Page