1.fp 5 CW
2.de Af
3.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
4.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
5..
6.de aF
7.ie \\$3 .ft \\$1
8.el \{\
9.ds ;G \&
10.nr ;G \\n(.f
11.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
12\\*(;G
13.ft \\n(;G \}
14..
15.de L
16.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
17..
18.de LR
19.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
20..
21.de RL
22.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
23..
24.de EX		\" start example
25.ta 1i 2i 3i 4i 5i 6i
26.PP
27.RS 
28.PD 0
29.ft 5
30.nf
31..
32.de EE		\" end example
33.fi
34.ft
35.PD
36.RE
37.PP
38..
39.TH STRMATCH 3
40.SH NAME
41strmatch \- match shell file patterns
42.SH SYNOPSIS
43.L "int strmatch(char* s, char* p)"
44.br
45.L "char* submatch(char* s, char* p, int m)"
46.SH DESCRIPTION
47.I strmatch
48compares the string
49.I s
50with the shell pattern
51.I p
52and returns 1 for match and 0 otherwise.
53.I submatch
54does a leading substring match of the shell pattern
55.I p
56with the string
57.IR s .
58If
59.I m
60is 0 then the match is minimal, otherwise a maximal match is done.
61A pointer to the first character after the matched substring is returned,
62.I 0
63if there is no match.
64.PP
65Except for
66.I &
67and
68.IR ! ,
69each shell pattern has an equivalent 
70.IR egrep (1)
71construct.
72.EX
73	\fBsh pattern	egrep RE	description\fP
74	*		.*		0 or more chars
75	?		.		any single char
76	[.]		[.]		char class
77	[!.]		[^.]		negated char class
78	*(.)		(.)*		0 or more of
79	+(.)		(.)+		1 or more of
80	?(.)		(.)?		0 or 1 of
81	(.)		(.)		1 of
82	@(.)		(.)		1 of
83	a|b		a|b		a or b
84	a&b				a and b
85	!(.)				none of
86.EE
87.L \e
88is used to escape *, ?, (, |, &, ), [, and \e
89outside of [...].
90.SH "SEE ALSO"
91grep(1)
92.SH BUGS
93An unbalanced
94.L )
95terminates the top level pattern.
96.br
97Nested
98.L &
99and
100.L !
101constructs are non-intuitive and are computationally intensive.
102