File: regex.7

package info (click to toggle)
manpages-ja 0.5.0.0.20100315-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 21,156 kB
  • ctags: 1
  • sloc: sh: 13,935; perl: 157; makefile: 114
file content (306 lines) | stat: -rw-r--r-- 13,579 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
.\" From Henry Spencer's regex package (as found in the apache
.\" distribution). The package carries the following copyright:
.\"
.\"  Copyright 1992, 1993, 1994 Henry Spencer.  All rights reserved.
.\"  This software is not subject to any license of the American Telephone
.\"  and Telegraph Company or of the Regents of the University of California.
.\"
.\"  Permission is granted to anyone to use this software for any purpose
.\"  on any computer system, and to alter it and redistribute it, subject
.\"  to the following restrictions:
.\"
.\"  1. The author is not responsible for the consequences of use of this
.\"     software, no matter how awful, even if they arise from flaws in it.
.\"
.\"  2. The origin of this software must not be misrepresented, either by
.\"     explicit claim or by omission.  Since few users ever read sources,
.\"     credits must appear in the documentation.
.\"
.\"  3. Altered versions must be plainly marked as such, and must not be
.\"     misrepresented as being the original software.  Since few users
.\"     ever read sources, credits must appear in the documentation.
.\"
.\"  4. This notice may not be removed or altered.
.\"
.\" In order to comply with `credits must appear in the documentation'
.\" I added an AUTHOR paragraph below - aeb.
.\"
.\" In the default nroff environment there is no dagger \(dg.
.\"
.\" 2005-05-11 Removed discussion of `[[:<:]]' and `[[:>:]]', which
.\" 	appear not to be in the glibc implementation of regcomp
.\"
.ie t .ds dg \(dg
.el .ds dg (!)
.\"
.\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
.\" Translated Wed 8 Jul 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\"
.\"WORD:	regular expression	ɽ
.\"WORD:	modern RE		ɽ
.\"WORD:	obsolete RE		Ťɽ
.\"WORD:	basic RE		ɽ
.\"WORD:	extended RE		ĥɽ
.\"WORD:	branch			
.\"WORD:	piece			ʸ
.\"WORD:	atom			ȥ
.\"WORD:	bound			֤
.\"WORD:	bracket expression	֥饱åɽ
.\"WORD:	digit			
.\"WORD:	collating sequence	ȹ
.\"WORD:	collating element	ȹ
.\"WORD:	character class		ʸ饹
.\"WORD:	equivalent class	饹
.\"WORD:	substring		ʬʸ
.\"WORD:	subexpression		ʬɽ
.\"
.TH REGEX 7 2009-01-12 "" "Linux Programmer's Manual"
.SH ̾
regex \- POSIX.2 ɽ
.SH 
ɽ (Regular expression: RE)  POSIX.2 Ƥꡢ
Ĥη롣ɽ (modern RE) ȸŤɽ (obsolete RE)
Ǥ롣ɽϤ
.I egrep
ΤΤƱǡ POSIX.2 Ǥϡֳĥɽ ("extended" RE)
ȸƤФƤ롣ŤɽϤ
.BR ed (1)
ΤΤƱǡ POSIX.2 Ǥϡִܡɽ ("basic" RE) Ǥ롣
ŤɽϡŤץȤθߴݤĤΤΤǤ롣
ˤĤƤϺǸ˵롣
POSIX.2 Ǥϡɽʸˡ䵭ΰ̤Τޤ޻ĤƤ롣
"\*(dg" ϡΤ褦ʰ̣ǡ¾ POSIX.2 μ
ˤϸߴǤʤΤʤʬǤ롣
.PP
() ɽϰİʾ\*(dg ζǤʤ \fI (branch)\fP ʤ롣
ޤɤ \(aq|\(aq Ƕڤ롣ɽϡ
ޤΤɤ줫˥ޥå (match) Τ˥ޥå롣
.PP
ޤϰİʾʸ (piece) 礵줿ΤǤ롣
ޤʸ᤬ޥå
³ʸ᤬ޥå... Τ˥ޥå롣
.PP
ʸ\fIȥ (atom)\fR ʤ롣ȥθˤϰ\*(dg  \(aq*\(aq,
\(aq+\(aq, \(aq?\(aq 뤤 \fI֤ (bound)\fR ³Ȥ⤢롣
\(aq*\(aq ֤줿ȥϡޥåȥ 0 İʾ¤Ӥ˥ޥå롣
\(aq+\(aq ֤줿ȥϡޥåȥ 1 İʾ¤Ӥ˥ޥå롣
\(aq?\(aq ֤줿ȥϡޥåȥ 0 Ĥޤ 1 Ĥ˥ޥå롣
.PP
\fI֤\fRȤ \(aq{\(aq ³ơʤ 10 \(aq,\(aq
⤦Ĥ 10 \(aq}\(aq ¤٤ΤǤ롣\(aq,\(aq Ĥ
10 ϾάǤ롣Ĥ 10 ά뤳ȤǤ
(Ǹ `}' ϾάǤʤ)
 0 ʾ
.B RE_DUP_MAX
(255\*(dg) ʲδ֤ǻǤ롣
ĻꤹˤϡǽοͤϸοͤۤƤϤʤʤ
 \fIi\fR ʤ뷫֤֤줿ȥϡ
ȥԤä礦 \fIi\fR Ĥ¤٤Τ˥ޥå롣
 \fIi\fR ȥޤꤵ줿֤֤줿ȥϡ
ȥ \fIi\fRİʾ¤٤Τ˥ޥå롣
 \fIi\fR  \fIj\fR ꤵ줿֤֤줿ȥϡ
ȥ \fIi\fRİʾ \fIj\fR İʲ¤٤Τ˥ޥå롣
.PP
ȥμϰʲ̤ꡣ"\fI()\fP" ˰Ϥޤ줿ɽ
(ɽޥåʸ˥ޥå)
Ȥ "\fI()\fP" (null ʸ˥ޥå)\*(dg
\fI֥饱åɽ (bracket expression\fR :)
\(aq.\(aq (Ǥդ 1 ʸ˥ޥå)
\(aq^\(aq (Ƭζʸ˥ޥå)
\(aq$\(aq (ζʸ˥ޥå)
\(aq\e\(aq  "\fI^.[$()|*+?{\e\fP" Τ줫ʸ֤
(̾ʸȤư졢ʸ˥ޥå)
\(aq\e\(aq ˤʳʸ֤\*(dg
(\(aq\e\(aq ʤƱ褦ˡʸ˥ޥå\*(dg)
ä˰̣ʤʸ (ʸ˥ޥå)
\(aq{\(aq Ͽʳʸ֤̾ʸȤư졢
֤λϤޤȤϤʤ\*(dg\(aq\e\(aq
ǽɽʤΤȤߤʤ롣
.PP
\fI֥饱åɽ\fR "\fI[]\fP" ˤäĤ줿ʸΥꥹȤǤ롣
̾ꥹ¸ߤƤʸ˥ޥå롣
(㳰ꡢҡ) ꥹȤ \(aq^\(aq ǻϤޤȡ
\fI֥饱åɽ\fRϥꥹȤ¸ߤ\fIʤ\fRʸĤ˥ޥå
(㳰ꡢ) ꥹĤʸ \(aq\-\(aq ǶڤƤϡ
Ͼȹ (collating sequence) ǤĤʸ˶ޤ롢
٤Ƥʸ¤Ӥṳ̂ΤȤߤʤ (ξüޤ)
㤨 "\fI[0\-9]\fP"  ASCII Ǥ 10 ʤο (digit) Τ줫˥ޥå롣
Ĥΰ꤬üͭƤϤʤʤ\*(dg
Ĥޤ "\fIa-c-e\fP" Τ褦ʤΤǤ롣ΰϾȹ˶¸롣
äưܿι⤤ץϡ
ΰˤʤۤɤ
.PP
: ȹ (collating sequence) ȤΤϡݲ
(Internationalization) ˴ϢѸǤե٥åȽñ
٤ݤˤϡˤä¤٤बۤʤޤȹϡκۤ
ۼ뤿λȤߤǤ
.PP
㤨СڥǤ ch Ȥʸ¤Ӥ̰뤿ᡢե٥
Ƚ礬 a, b, c, ch, d, e, ... νˤʤ뤽ǤΤ褦ʥ
ΤȤ collating sequence ȸޤΤȤ `ch' Ȥʸ¤Ӥϡ
ñκݤˤְʸפΤ褦˰ޤǡ
դԤݤ˺Ǿñ̤Ȥʤ롢`a'`b' ʸ
`ch' Τ褦̤ʸ¤ӤʤɡȹǤΤȤ
collating element ȸޤcollating sequence ϡʸñ̤ǤϤʤ
collating element ñ̤Ȥޤ
.PP
ʸ \(aq]\(aq ΤΤꥹȤ줿ϡ
ǽʸȤƻꤹɤ (\(aq^\(aq) θ³ΤǤɤ)
ʸ \(aq\-\(aq ΤΤꥹȤ줿ϡ
ǽ餫ǸʸȤɤ
뤤ΰνüʸȤƻꤷƤɤ
\(aq\-\(aq ΰƬʸ˻ꤹˤϡ"\fI[.\fP"  "\fI.]\fP" ǰϤäơ
ȹ (collating element: ) ˤɤ
¾üʸ ( ޤ) ϡ
֥饱åɽǤϤ٤̾ʸȤư롣
.PP
֥饱åɽǤϡ"\fI[.\fP"  "\fI.]\fP" ˰Ϥ줿ȹǤϡ
Ǥбʸ¤Ӥɽ
־ȹǡפȤϡ
[1] ʸ [2] ñʸΤ褦˰ʣʸΥ󥹡
[3] 1, 2 줫бȹ̾Τ줫Ǥ롣
η֤ϡ֥饱åɽΥꥹȤˤñǤȤʤ롣
嵭 [2] Ρʣʸʤȹǡפޤ֥饱åɽϡ
äưʸʾ˥ޥå뤳Ȥ롣
㤨С⤷ȹ "ch" ȤǤޤǤˤϡ
ɽ "\fI[[.ch.]]*c\fP"  "chchcc" κǽ 5 ʸ˥ޥå롣
.PP
֥饱åɽǤϡ"\fI[=\fP"  "\fI=]\fP" ˰Ϥޤ줿ȹǤϡ
饹 (equivalence class) Ȥʤ롣
ϡǤǤ٤Ƥʤʸ (Ȥޤ) ɽ
¾ǤʤС
갷 "\fI[.\fP"  "\fI.]\fP" ǰϤޤƤƱǤ롣
㤨 o  ou 饹ΥСǤС
"\fI[[=o=]]\fP", "\fI[[=\o'o^'=]]\fP", "\fI[o\o'o^']\fP" Ϥ٤Ʊ̣ˤʤ롣
饹ΰüˤϤʤʤ\*(dg
.\" nippon üǤ \o'o^' ФʤΤǡ㼨ѹޤ
.PP
֥饱åɽǤϡ"\fI[:\fP"  "\fI:]\fP" ǰϤ줿\fIʸ饹
(character class)\fR ϤΥ饹°뤹٤ƤʸΥꥹȤɽ
ɸѰդƤʸ饹̾ϰʲ̤:
.PP
.RS
.nf
.ta 3c 6c 9c
alnum	digit	punct
alpha	graph	space
blank	lower	upper
cntrl	print	xdigit
.fi
.RE
.PP

.BR wctype (3)
Ƥʸ饹ɽƤ롣 (locale) ˤäơ
ʳΥ饹뤳Ȥ⤢롣
ʸ饹ΰüˤϤʤʤ
.\" .PP
.\" http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295666 ˤ褦
.\" ʲεܤ glibc μˤϤƤϤޤʤ褦Ǥ롣
.\" ֥饱åɽˤϡüʰ̣ĤΤ¸ߤ\*(dg
.\" ֥饱åɽ "\fI[[:<:]]\fP" ϥ (word) ƬΥ̥ʸˡ
.\" "\fI[[:>:]]\fP" ϥΥ̥ʸˤ줾ޥå롣
.\" ɤȤϥʸ¤ӤǤꡢ
.\" ʸ֤֤⤵ƤʤΤǤ롣
.\" ʸ
.\" .I alnum
.\" ʸ
.\" .RB ( wctype (3)
.\" Ƥ) ӥ `_' Ǥ롣
.\" ϳĥˡǤꡢPOSIX.2 ȿƤϤʤ
.\" ⤵Ƥʤ
.\" ¾ΥƥȸߴݤեȥǤϡ
.\" դѤ褦ˤ뤳ȡ
.PP
ɽͿ줿ʸʣʬʸ
(substring) ˥ޥåǤ褦ʾˤϡ
ǤƬζ᤯ϤޤΤ˥ޥå롣
ΰ֤ϤޤꡢɽޥåǤʬʸʣˤϡ
ĹΤΤ˥ޥå롣
ʬɽ (subexpression) ǤĹʬʸ˥ޥå롣
ΤΥޥåĹǤ褦ˡȤ郎ͥ褵롣
ɽ˸ʬɽϡ˸Τͥ褵롣
̤ʬɽϡ
̤ʬɽͥ褵뤳Ȥդ뤳ȡ
.PP
ޥåĹϾȹǤǤϤʤʸñ̤ȤƥȤ롣
null ʸϡޥåʤäĹȤߤʤ롣
㤨 "\fIbb*\fP"  "abbbc" Τޤ 3 ʸ˥ޥå롣
"\fI(wee|week)(knights|nights)\fP"  "weeknights" Τ˥ޥå롣
"\fI(.*).*\fP"  "abc" ˥ޥåȡ
̤ʬɽ 3 ʸ٤Ƥ˥ޥå롣
"\fI(a*)*\fP"  "bc" ˥ޥåȡɽΤ⡢
̤dz줿ʬɽ null ʸ˥ޥå롣
.PP
ޥåʸʸ̵뤹褦˻ꤵȡ
ե٥åΤ羮ʸζ̵̤ʤäΤ褦ʸ̤Ȥʤ롣
ʸʸĥե٥åȤ֥饱åɽγ
̾ʸȤƸȡ
ϼ¸Ū羮ξʸΥ֥饱åɽΤ褦Ѵ롣
ʤ \(aqx\(aq  "\fI[xX]\fP" Ȥʤ롣֥饱åɽ˸ȡ
ʸʤ龮ʸʸʤʸΥ֥饱åɽ˲ä롣
ʤ
"\fI[x]\fP"  "\fI[xX]\fP" ˡ"\fI[^x]\fP"  "\fI[^xX]\fP" ˤʤ롣
.PP
ɽĹˤä¤Ϥʤ\*(dg
ܿ⤯ץǤϡ
256 ХȤĹɽϼ¹Ԥʤ褦ˤۤɤ
ʤʤ顢Τ褦ɽݤ
 POSIX ߴݤĤ褦ʼǽǤ롣
.PP
Ť ("") ɽϡĤˤưۤʤ롣
\(aq|\(aq, \(aq+\(aq, and \(aq?\(aq ̾ʸȤʤ롣
б뵡ǽ¸ߤʤ֤ζڤ
"\fI\e{\fP"  "\fI\e}\fP" Ȥʤ롣\(aq{\(aq  \(aq}\(aq ϡ
ñȤǤ̾ʸȤư롣
ʬɽͥȤ̤ "\fI\e(\fP"  "\fI\e)\fP" Ȥʤꡢ
\(aq(\(aq  \(aq)\(aq ñȤǤ̾ʸȤʤ롣
\(aq^\(aq ɽƬ
̤Ǥ줿ʬɽƬ\*(dg̾ʸȤʤ롣
\(aq$\(aq ɽ
̤Ǥ줿ʬɽ\*(dg̾ʸȤʤ롣
\(aq*\(aq ϡɽƬ
̤Ǥ줿ʬʸƬ֤줿̾ʸȤʤ
(\(aq^\(aq) ֤ƤƤ褤)
.PP
ǸˡȥȤ̤Υפ¸ߤ롣
\fI (back reference)\fR Ǥ롣
\(aq\e\(aq θ 0 Ǥʤ 10 ʿʸ \fId\fR ³ȡ
̤Ǥ줿ʬɽ
\fId\fR ܤ˥ޥåʸ¤ӤƱΤ˥ޥå롣
(ʬɽֹդϡ
 `(' ΰ֤ΤΤ鱦ΤΤظäƤʤ롣)
ä "\fI\e([bc]\e)\e1\fP" 
"bb" ޤ "cc" ˤϥޥå뤬"bc" ˤϥޥåʤ
.SH Х
ɽ 2 ढΤϳʹ
.PP
ߤ POSIX.2 ʤˤƤϡ\(aq)\(aq ϡ
б \(aq(\(aq ʤˤ̾ʸȤư뤳ȤˤʤäƤ롣
ϡΰտޤȤϰۤʤ뵭ҾΥ顼Ǥꡢ
ǽ⤤˰¸ɤϻȤʤȡ
.PP
ȤϤҤɤΰʪǤ롣
Ψɤ򤹤ΤϤȤƤ񤷤
ޤޤǤ롣
("\fIa\e(\e(b\e)*\e2\e)*d\fP"  "abbbd" ˥ޥåȻפ)
Ȥʤۤɤ
.PP
POSIX.2 εʤǤϡcase (ʸʸ)
˰¸ʤޥåεҤޤǤ롣
ߤΤȤǤϡְĤ case ٤Ƥ case ̣
Ȥ嵭ǤȤΤ
Ԥδ֤ǤζǧΤ褦Ǥ롣
.\" As per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295666
.\" The following does not seem to apply in the glibc implementation
.\" .PP
.\" ɶ˴ؤʸˡ˽
.SH 
.\" Sigh... The page license means we must have the author's name
.\" in the formatted output.
Υڡ Henry Spencer  regex ѥåϿΤǤ롣
.SH Ϣ
.BR grep (1),
.BR regex (3)
.PP
POSIX.2, section 2.8 (Regular Expression Notation).