NetBSD/share/man/man9/pmatch.9

69 lines
2.2 KiB
Groff

.\" $NetBSD: pmatch.9,v 1.3 2009/10/19 18:41:09 bouyer Exp $
.\"
.\" Copyright (c) 2003 Manuel Bouyer.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
.Dd October 12, 2003
.Dt PMATCH 9
.Os
.Sh NAME
.Nm pmatch
.Nd performs pattern matching on strings
.Sh SYNOPSIS
.In sys/systm.h
.Ft int
.Fn pmatch "const char *string" "const char *pattern" "const char **estr"
.Sh DESCRIPTION
Extract substring matching
.Fa pattern
from
.Fa string .
If not
.Dv NULL ,
.Fa estr
points to the end of the longest exact or substring match.
.Pp
.Fn pmatch
uses the following metacharacters:
.Bl -tag -width Ds
.It Li \&?
match any single character.
.It Li *
match any character 0 or more times.
.It Li \&[
define a range of characters that will match.
The range is defined by 2 characters separated by a
.Sq Li \&- .
The range definition has to end with a
.Sq Li \&] .
A
.Sq Li ^
following the
.Sq Li \&[
will negate the range.
.El
.Sh RETURN VALUES
.Fn pmatch
will return 2 for an exact match, 1 for a substring match, 0 for no match and
\-1 if an error occurs.