reference/filesystem/functions/fnmatch.xml
39a98b1f1776afd4c41f79ce528309c95f62b10a
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fnmatch">
3
+
<refentry xml:id="function.fnmatch" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>fnmatch</refname>
6
6
<refpurpose>Match filename against a pattern</refpurpose>
...
...
@@ -11,11 +11,11 @@
11
11
<methodsynopsis>
12
12
<type>bool</type><methodname>fnmatch</methodname>
13
13
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
14
-
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14
+
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
15
15
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
-
<function>fnmatch</function> checks if the passed <parameter>string</parameter> would
18
+
<function>fnmatch</function> checks if the passed <parameter>filename</parameter> would
19
19
match the given shell wildcard <parameter>pattern</parameter>.
20
20
</para>
21
21
</refsect1>
...
...
@@ -28,12 +28,80 @@
28
28
<term><parameter>pattern</parameter></term>
29
29
<listitem>
30
30
<para>
31
-
The shell wildcard pattern.
31
+
The <parameter>pattern</parameter> to match against. Usually, the <parameter>pattern</parameter> will contain
32
+
wildcards like <literal>'?'</literal> and <literal>'*'</literal>.
33
+
<table>
34
+
<title>
35
+
Wildcards to be used in <parameter>pattern</parameter> parameter
36
+
</title>
37
+
<tgroup cols="2">
38
+
<thead>
39
+
<row>
40
+
<entry>Wildcard</entry>
41
+
<entry>&Description;</entry>
42
+
</row>
43
+
</thead>
44
+
<tbody>
45
+
<row>
46
+
<entry>
47
+
<literal>?</literal>
48
+
</entry>
49
+
<entry>
50
+
Question mark will match any single character.
51
+
For example, pattern <literal>"file?.txt"</literal> will match <literal>"file1.txt"</literal> and
52
+
<literal>"fileA.txt"</literal>, but will not match <literal>"file10.txt"</literal>.
53
+
</entry>
54
+
</row>
55
+
<row>
56
+
<entry>
57
+
<literal>*</literal>
58
+
</entry>
59
+
<entry>
60
+
Asterisk will match zero or more characters.
61
+
For example, pattern <literal>"foo*.xml"</literal> will match <literal>"foo.xml"</literal> and
62
+
<literal>"foobar.xml"</literal>.
63
+
</entry>
64
+
</row>
65
+
<row>
66
+
<entry>
67
+
<literal>[ ]</literal>
68
+
</entry>
69
+
<entry>
70
+
Square brackets are used to create ranges of ASCII codepoints or sets of characters.
71
+
For example, pattern <literal>"index.php[45]"</literal> will match <literal>"index.php4"</literal> and
72
+
<literal>"index.php5"</literal>, but will not match <literal>"index.phpt"</literal>.
73
+
Well known ranges are <literal>[0-9]</literal>, <literal>[a-z]</literal>, and <literal>[A-Z]</literal>.
74
+
Multiple sets and ranges can be used at the same time, for example <literal>[0-9a-zABC]</literal>.
75
+
</entry>
76
+
</row>
77
+
<row>
78
+
<entry>
79
+
<literal>!</literal>
80
+
</entry>
81
+
<entry>
82
+
Exclamation mark is used to negate characters within square brackets.
83
+
For example, <literal>"[!A-Z]*.html"</literal> will match <literal>"demo.html"</literal>, but will not match
84
+
<literal>"Demo.html"</literal>.
85
+
</entry>
86
+
</row>
87
+
<row>
88
+
<entry>
89
+
<literal>\</literal>
90
+
</entry>
91
+
<entry>
92
+
Backslash is used to escape special characters.
93
+
For example, <literal>"Name\?"</literal> will match <literal>"Name?"</literal>, but will not match
94
+
<literal>"Names"</literal>.
95
+
</entry>
96
+
</row>
97
+
</tbody>
98
+
</tgroup>
99
+
</table>
32
100
</para>
33
101
</listitem>
34
102
</varlistentry>
35
103
<varlistentry>
36
-
<term><parameter>string</parameter></term>
104
+
<term><parameter>filename</parameter></term>
37
105
<listitem>
38
106
<para>
39
107
The tested string. This function is especially useful for filenames,
...
...
@@ -109,30 +177,6 @@
109
177
</para>
110
178
</refsect1>
111
179

112
-
<refsect1 role="changelog">
113
-
&reftitle.changelog;
114
-
<para>
115
-
<informaltable>
116
-
<tgroup cols="2">
117
-
<thead>
118
-
<row>
119
-
<entry>&Version;</entry>
120
-
<entry>&Description;</entry>
121
-
</row>
122
-
</thead>
123
-
<tbody>
124
-
<row>
125
-
<entry>5.3.0</entry>
126
-
<entry>
127
-
This function is now available on Windows platforms.
128
-
</entry>
129
-
</row>
130
-
</tbody>
131
-
</tgroup>
132
-
</informaltable>
133
-
</para>
134
-
</refsect1>
135
-

136
180
<refsect1 role="examples">
137
181
&reftitle.examples;
138
182
<para>
...
...
@@ -175,7 +219,6 @@ if (fnmatch("*gr[ae]y", $color)) {
175
219
</refsect1>
176
220

177
221
</refentry>
178
-

179
222
<!-- Keep this comment at the end of the file
180
223
Local variables:
181
224
mode: sgml
182
225