1 .\" Copyright (C), 1995, Graeme W. Wilford. (Wilf.)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Wed Jun 14 16:10:28 BST 1995 Wilf. (G.Wilford@ee.surrey.ac.uk)
24 .\" Tiny change in formatting - aeb, 950812
25 .\" Modified 8 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk)
27 .\" Japanese Version Copyright (c) 1998 Takatsugu Nokubi
28 .\" all rights reserved.
29 .\" Translated 1998-06-30, Takatsugu Nokubi
30 .\" Updated & Modified 2001-11-05, Yuichi SATO <ysato@h4.dion.ne.jp>
31 .\" Updated & Modified 2005-02-24, Yuichi SATO <ysato444@yahoo.co.jp>
32 .\" Updated 2008-08-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
34 .\"WORD: bitwise-or ビットごとのOR
35 .\"WORD: element (構造体)要素
36 .\"WORD: collating element 照合順序の要素
38 .\" show the synopsis section nicely
43 .TH REGEX 3 2011-09-27 "GNU" "Linux Programmer's Manual"
46 .\"O regcomp, regexec, regerror, regfree \- POSIX regex functions
47 regcomp, regexec, regerror, regfree \- POSIX regex 関数
51 .B #include <sys/types.h>
54 .BI "int regcomp(regex_t *" preg ", const char *" regex ", int " cflags );
56 .BI "int regexec(const regex_t *" preg ", const char *" string \
58 .BI " regmatch_t " pmatch[] ", int " eflags );
60 .BI "size_t regerror(int " errcode ", const regex_t *" preg ", char *" errbuf ,
61 .BI " size_t " errbuf_size );
63 .BI "void regfree(regex_t *" preg );
67 .\"O .SS "POSIX Regex Compiling"
68 .SS "POSIX regex コンパイル"
70 .\"O is used to compile a regular expression into a form that is suitable
82 .\"O a pointer to a pattern buffer storage area;
84 .\"O a pointer to the null-terminated string and
86 .\"O flags used to determine the type of compilation.
96 .\"O All regular expression searching must be done via a compiled pattern
99 .\"O must always be supplied with the address of a
101 .\"O initialized pattern buffer.
102 全ての正規表現検索は、コンパイルされたパターンによって行わなければならない。
107 によってコンパイルされた) パターンバッファへのアドレスでなければならない。
112 .\"O of one or more of the following:
114 には以下に示す定数一つ以上のビットごとの OR (bitwise-or) を指定する。
119 .\"O Extended Regular Expression syntax when interpreting
123 .\"O Basic Regular Expression syntax is used.
127 拡張正規表現を使用する。もしこのフラグが設定されない場合、
132 .\"O Do not differentiate case.
135 .\"O searches using this pattern buffer will be case insensitive.
136 大文字小文字の違いを無視する。このフラグを指定してコンパイルされた
139 関数を呼び出すと、大文字小文字の区別を付けずに検索が行われる。
142 .\"O Support for substring addressing of matches is not required.
149 .\"O are ignored if the pattern buffer supplied was compiled with this flag set.
150 このフラグを設定してコンパイルされたパターンバッファが
158 .\"O Match-any-character operators don't match a newline.
159 全ての文字にマッチするオペレータに改行をマッチさせない。
161 .\"O A nonmatching list
163 .\"O not containing a newline does not match a newline.
168 .\"O Match-beginning-of-line operator
170 .\"O matches the empty string immediately after a newline, regardless of
173 .\"O the execution flags of
176 .\"O .BR REG_NOTBOL .
182 を含むかどうかにかかわらず、行頭にマッチするオペレータ
186 .\"O Match-end-of-line operator
188 .\"O matches the empty string immediately before a newline, regardless of
192 .\"O .BR REG_NOTEOL .
196 を含むかどうかにかかわらず、行末にマッチするオペレータ
199 .\"O .SS "POSIX Regex Matching"
200 .SS "POSIX regex マッチング"
202 .\"O is used to match a null-terminated string
203 .\"O against the precompiled pattern buffer,
209 をヌル文字で終端された文字列にマッチさせる。
213 .\"O are used to provide information regarding the location of any matches.
217 はマッチングの位置に関する情報を取得するのに用いられる。
221 .\"O of one or both of
225 .\"O which cause changes in matching behavior described below.
232 .BR OR " (bitwise-" or )
233 を指定し、以下で説明するようにマッチング動作を変化させる。
236 .\"O The match-beginning-of-line operator always fails to match (but see the
237 .\"O compilation flag
241 行頭にマッチするオペレータは、必ずマッチに失敗する (コンパイル時のフラグ
244 .\"O This flag may be used when different portions of a string are passed to
246 .\"O and the beginning of the string should not be interpreted as the
247 .\"O beginning of the line.
250 で検索する際に、文字列の先頭を行の先頭として解釈させない場合に用いる。
253 .\"O The match-end-of-line operator always fails to match (but see the
254 .\"O compilation flag
258 行末にマッチするオペレータは、必ずマッチに失敗する (コンパイル時のフラグ
261 .\"O .SS "Byte Offsets"
265 .\"O was set for the compilation of the pattern buffer, it is possible to
266 .\"O obtain substring match addressing information.
269 が設定されない場合は、部分文字列のマッチング位置情報を得ることができる。
271 .\"O must be dimensioned to have at least
277 の大きさを持つように指定しなければならない。
278 .\"O These are filled in by
280 .\"O with substring match addresses.
281 .\"O Any unused structure elements
282 .\"O will contain the value \-1.
284 の実行によって、それらに部分文字列マッチング位置情報が代入される。
285 未使用の構造体要素には \-1 が値として代入される。
289 .\"O structure which is the type of
311 .\"O element that is not \-1 indicates the start offset of the next largest
312 .\"O substring match within the string.
315 .\"O element indicates the end offset of the match,
316 .\"O which is the offset of the first character after the matching text.
319 の値が \-1 でない場合、それは文字列内での次の最大のマッチング部分の開始
320 オフセット位置を示す。それに対し、構造体要素
322 はマッチング部分の終了オフセット位置を示し、
323 マッチング部分の直後の文字のオフセット位置が使用される。
324 .\"O .SH "POSIX Error Reporting"
327 .\"O is used to turn the error codes that can be returned by both
331 .\"O into error message strings.
337 の実行によって得られるエラーコードから、エラーメッセージ文字列を
341 .\"O is passed the error code,
343 .\"O the pattern buffer,
345 .\"O a pointer to a character string buffer,
347 .\"O and the size of the string buffer,
348 .\"O .IR errbuf_size .
359 .\"O It returns the size of the
361 .\"O required to contain the null-terminated error message string.
368 .\"O is filled in with the first
369 .\"O .I "errbuf_size \- 1"
370 .\"O characters of the error message and a terminating null byte (\(aq\\0\(aq).
371 この関数は、ヌル文字で終端されたエラーメッセージ文字列を格納するのに必要な
380 .I "errbuf_size \- 1"
381 文字分にエラーメッセージと終端の NULL バイト (\(aq\\0\(aq)
383 .\"O .SS "POSIX Pattern Buffer Freeing"
384 .SS "POSIX パターンバッファ解放"
387 .\"O with a precompiled pattern buffer,
389 .\"O will free the memory allocated to the pattern buffer by the compiling
398 によるコンパイル時にパターンバッファに割り当てられたメモリが解放される。
399 .\"O .SH "RETURN VALUE"
402 .\"O returns zero for a successful compilation or an error code for failure.
404 は、コンパイルの成功時には 0 を返し、失敗時にはエラーコードを返す。
407 .\"O returns zero for a successful match or
411 は、マッチングの成功時には 0 を返し、失敗時には
416 .\"O The following errors can be returned by
422 .\"O Invalid use of back reference operator.
426 .\"O Invalid use of pattern operators such as group or list.
427 グループやリストなどの、パターンオペレータの無効な使用。
430 .\"O Invalid use of repetition operators such as using \(aq*\(aq
431 .\"O as the first character.
432 \(aq*\(aq が最初の文字としてくるような、無効な繰り返しオペレータの使用。
435 .\"O Un-matched brace interval operators.
438 (brace interval operators) が閉じていない。
441 .\"O Un-matched bracket list operators.
444 (bracket list operators) が閉じていない。
447 .\"O Invalid collating element.
448 照合順序の要素 (collating element) として有効ではない。
450 (訳注) 照合順序の要素 (collating element) については、
455 .\"O Unknown character class name.
459 .\"O Non specific error.
460 .\"O This is not defined by POSIX.2.
461 未定義エラー。これは POSIX.2 には定義されていない。
464 .\"O Trailing backslash.
467 (訳注) 日本語環境の場合、バックスラッシュとなるべき所が円記号で
468 表示されることがあるが、これは単に表示フォントの問題で、
472 .\"O Un-matched parenthesis group operators.
475 (parenthesis group operators) が閉じていない。
478 .\"O Invalid use of the range operator, e.g., the ending point of the range
479 .\"O occurs prior to the starting point.
481 例えば、範囲の終了位置が開始位置よりも前にあるような場合。
484 .\"O Compiled regular expression requires a pattern buffer larger than 64Kb.
485 .\"O This is not defined by POSIX.2.
486 正規表現のコンパイルに、64Kb 以上のパターンバッファが必要。
487 これは POSIX.2 には定義されていない。
490 .\"O The regex routines ran out of memory.
491 regex ルーチンがメモリを使いはたしている。
494 .\"O Invalid back reference to a subexpression.
497 (subexpression) への無効な後方参照。
498 .\"O .SH "CONFORMING TO"
505 .\"O GNU regex manual