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 2008-05-29 "GNU" "Linux Programmer's Manual"
45 regcomp, regexec, regerror, regfree \- POSIX regex ´Ø¿ô
48 .B #include <sys/types.h>
51 .BI "int regcomp(regex_t *" preg ", const char *" regex ", int " cflags );
53 .BI "int regexec(const regex_t *" preg ", const char *" string \
55 .BI " regmatch_t " pmatch[] ", int " eflags );
57 .BI "size_t regerror(int " errcode ", const regex_t *" preg ", char *" errbuf ,
58 .BI " size_t " errbuf_size );
60 .BI "void regfree(regex_t *" preg );
63 .SS "POSIX regex ¥³¥ó¥Ñ¥¤¥ë"
65 ¤Ï¡¢Àµµ¬É½¸½¤ò¥³¥ó¥Ñ¥¤¥ë¤·¤Æ¡¢
67 ¤Ç¤Î¸¡º÷½èÍý¤ËŬ¹ç¤¹¤ë·ÁÂ֤ˤ¹¤ë¡£
70 ¤Ï¥Ñ¥¿¡¼¥ó¤òµ²±¤¹¤ë¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿
72 ¥Ì¥ëʸ»ú¤Ç½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó
74 ¤½¤·¤Æ¥³¥ó¥Ñ¥¤¥ë¤Î·Á¼°¤ò·è¤á¤ë¤¿¤á¤Î¥Õ¥é¥°
78 Á´¤Æ¤ÎÀµµ¬É½¸½¸¡º÷¤Ï¡¢¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥Ñ¥¿¡¼¥ó¤Ë¤è¤Ã¤Æ¹Ô¤ï¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
83 ¤Ë¤è¤Ã¤Æ¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿) ¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥¢¥É¥ì¥¹¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
86 ¤Ë¤Ï°Ê²¼¤Ë¼¨¤¹Äê¿ô°ì¤Ä°Ê¾å¤Î¥Ó¥Ã¥È¤´¤È¤Î OR (bitwise-or) ¤ò»ØÄꤹ¤ë¡£
92 ³ÈÄ¥Àµµ¬É½¸½¤ò»ÈÍѤ¹¤ë¡£¤â¤·¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Ê¤¤¾ì¹ç¡¢
94 ɸ½àÀµµ¬É½¸½¤¬»È¤ï¤ì¤ë¡£
97 Âçʸ»ú¾®Ê¸»ú¤Î°ã¤¤¤ò̵»ë¤¹¤ë¡£¤³¤Î¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿
98 ¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡¤òÍѤ¤¤Æ
100 ´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¤È¡¢Âçʸ»ú¾®Ê¸»ú¤Î¶èÊ̤òÉÕ¤±¤º¤Ë¸¡º÷¤¬¹Ô¤ï¤ì¤ë¡£
103 ¤³¤Î¥Õ¥é¥°¤òÀßÄꤷ¤Æ¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡¤¬
105 ¤Î°ú¿ô¤Ë»ØÄꤵ¤ì¤ë¤È¡¢°ú¤¿ô
111 Á´¤Æ¤Îʸ»ú¤Ë¥Þ¥Ã¥Á¤¹¤ë¥ª¥Ú¥ì¡¼¥¿¤Ë²þ¹Ô¤ò¥Þ¥Ã¥Á¤µ¤»¤Ê¤¤¡£
113 ²þ¹Ô¤ò´Þ¤Þ¤Ê¤¤Èó¥Þ¥Ã¥Á¥ó¥°Ê¸»ú¥ê¥¹¥È
115 ¤Ë²þ¹Ô¤ò¥Þ¥Ã¥Á¤µ¤»¤Ê¤¤¡£
118 ¤Î¼Â¹Ô»þ¤Ë»ØÄꤹ¤ë¥Õ¥é¥°
122 ¤ò´Þ¤à¤«¤É¤¦¤«¤Ë¤«¤«¤ï¤é¤º¡¢¹ÔƬ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥ª¥Ú¥ì¡¼¥¿
124 ¤ò²þ¹Ôľ¸å¤Î¶õʸ»úÎó¤Ë¥Þ¥Ã¥Á¤µ¤»¤ë¡£
129 ¤ò´Þ¤à¤«¤É¤¦¤«¤Ë¤«¤«¤ï¤é¤º¡¢¹ÔËö¤Ë¥Þ¥Ã¥Á¤¹¤ë¥ª¥Ú¥ì¡¼¥¿
131 ¤ò²þ¹ÔľÁ°¤Î¶õʸ»úÎó¤Ë¥Þ¥Ã¥Á¤µ¤»¤ë¡£
132 .SS "POSIX regex ¥Þ¥Ã¥Á¥ó¥°"
135 ¥×¥ê¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡
137 ¤ò¥Ì¥ëʸ»ú¤Ç½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤Ë¥Þ¥Ã¥Á¤µ¤»¤ë¡£
141 ¤Ï¥Þ¥Ã¥Á¥ó¥°¤Î°ÌÃ֤˴ؤ¹¤ë¾ðÊó¤ò¼èÆÀ¤¹¤ë¤Î¤ËÍѤ¤¤é¤ì¤ë¡£
147 ¤Î¤É¤Á¤é¤«¡¢¤â¤·¤¯¤ÏξÊý¤Î¥Ó¥Ã¥È¤´¤È¤Î
148 .BR OR " (bitwise-" or )
149 ¤ò»ØÄꤷ¡¢°Ê²¼¤ÇÀâÌÀ¤¹¤ë¤è¤¦¤Ë¥Þ¥Ã¥Á¥ó¥°Æ°ºî¤òÊѲ½¤µ¤»¤ë¡£
152 ¹ÔƬ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥ª¥Ú¥ì¡¼¥¿¤Ï¡¢É¬¤º¥Þ¥Ã¥Á¤Ë¼ºÇÔ¤¹¤ë (¥³¥ó¥Ñ¥¤¥ë»þ¤Î¥Õ¥é¥°
155 ¤³¤Î¥Õ¥é¥°¤Ï¡¢Ê£¿ô¹Ô¤Ë¤Þ¤¿¤¬¤ëʸ»úÎó¤ò
157 ¤Ç¸¡º÷¤¹¤ëºÝ¤Ë¡¢Ê¸»úÎó¤ÎÀèƬ¤ò¹Ô¤ÎÀèƬ¤È¤·¤Æ²ò¼á¤µ¤»¤Ê¤¤¾ì¹ç¤ËÍѤ¤¤ë¡£
160 ¹ÔËö¤Ë¥Þ¥Ã¥Á¤¹¤ë¥ª¥Ú¥ì¡¼¥¿¤Ï¡¢É¬¤º¥Þ¥Ã¥Á¤Ë¼ºÇÔ¤¹¤ë (¥³¥ó¥Ñ¥¤¥ë»þ¤Î¥Õ¥é¥°
164 ¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡¤Î¥³¥ó¥Ñ¥¤¥ë»þ¤Ë
166 ¤¬ÀßÄꤵ¤ì¤Ê¤¤¾ì¹ç¤Ï¡¢Éôʬʸ»úÎó¤Î¥Þ¥Ã¥Á¥ó¥°°ÌÃÖ¾ðÊó¤òÆÀ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
170 ¤ÎÂ礤µ¤ò»ý¤Ä¤è¤¦¤Ë»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
172 ¤Î¼Â¹Ô¤Ë¤è¤Ã¤Æ¡¢¤½¤ì¤é¤ËÉôʬʸ»úÎó¥Þ¥Ã¥Á¥ó¥°°ÌÃÖ¾ðÊó¤¬ÂåÆþ¤µ¤ì¤ë¡£
173 ̤»ÈÍѤι½Â¤ÂÎÍ×ÁÇ¤Ë¤Ï \-1 ¤¬ÃͤȤ·¤ÆÂåÆþ¤µ¤ì¤ë¡£
193 ¤ÎÃͤ¬ \-1 ¤Ç¤Ê¤¤¾ì¹ç¡¢¤½¤ì¤Ïʸ»úÎóÆâ¤Ç¤Î¼¡¤ÎºÇÂç¤Î¥Þ¥Ã¥Á¥ó¥°Éôʬ¤Î³«»Ï
194 ¥ª¥Õ¥»¥Ã¥È°ÌÃÖ¤ò¼¨¤¹¡£¤½¤ì¤ËÂФ·¡¢¹½Â¤ÂÎÍ×ÁÇ
196 ¤Ï¥Þ¥Ã¥Á¥ó¥°Éôʬ¤Î½ªÎ»¥ª¥Õ¥»¥Ã¥È°ÌÃÖ¤ò¼¨¤·¡¢
197 ¥Þ¥Ã¥Á¥ó¥°Éôʬ¤Îľ¸å¤Îʸ»ú¤Î¥ª¥Õ¥»¥Ã¥È°ÌÃÖ¤¬»ÈÍѤµ¤ì¤ë¡£
198 .SS "POSIX ¥¨¥é¡¼¥ì¥Ý¡¼¥È"
204 ¤Î¼Â¹Ô¤Ë¤è¤Ã¤ÆÆÀ¤é¤ì¤ë¥¨¥é¡¼¥³¡¼¥É¤«¤é¡¢¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸Ê¸»úÎó¤ò
212 ʸ»úÎó¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿
214 ʸ»úÎó¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º
217 ¤³¤Î´Ø¿ô¤Ï¡¢¥Ì¥ëʸ»ú¤Ç½ªÃ¼¤µ¤ì¤¿¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸Ê¸»úÎó¤ò³ÊǼ¤¹¤ë¤Î¤ËɬÍפÊ
223 ¤ÎξÊý¤¬Èó 0 ÃͤǤ¢¤ì¤Ð¡¢
226 .I "errbuf_size \- 1"
227 ʸ»úʬ¤Ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤È½ªÃ¼¤Î¥Ì¥ëʸ»ú¤¬¼ý¤Þ¤ë¤è¤¦¤ËÂåÆþ¤µ¤ì¤ë¡£
228 .SS "POSIX ¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡²òÊü"
229 °ú¿ô¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡
235 ¤Ë¤è¤ë¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿¥á¥â¥ê¤¬²òÊü¤µ¤ì¤ë¡£
238 ¤Ï¡¢¥³¥ó¥Ñ¥¤¥ë¤ÎÀ®¸ù»þ¤Ë¤Ï 0 ¤òÊÖ¤·¡¢¼ºÇÔ»þ¤Ë¤Ï¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤¹¡£
241 ¤Ï¡¢¥Þ¥Ã¥Á¥ó¥°¤ÎÀ®¸ù»þ¤Ë¤Ï 0 ¤òÊÖ¤·¡¢¼ºÇÔ»þ¤Ë¤Ï
246 ¤Ï°Ê²¼¤Î¥¨¥é¡¼¤òÊÖ¤¹¡£
249 ̵¸ú¤Ê¸åÊý»²¾È¥ª¥Ú¥ì¡¼¥¿¤Î»ÈÍÑ¡£
252 ¥°¥ë¡¼¥×¤ä¥ê¥¹¥È¤Ê¤É¤Î¡¢¥Ñ¥¿¡¼¥ó¥ª¥Ú¥ì¡¼¥¿¤Î̵¸ú¤Ê»ÈÍÑ¡£
255 \(aq*\(aq ¤¬ºÇ½é¤Îʸ»ú¤È¤·¤Æ¤¯¤ë¤è¤¦¤Ê¡¢Ìµ¸ú¤Ê·«¤êÊÖ¤·¥ª¥Ú¥ì¡¼¥¿¤Î»ÈÍÑ¡£
258 ¥¤¥ó¥¿¡¼¥Ð¥ë¥ª¥Ú¥ì¡¼¥¿
260 (brace interval operators) ¤¬ÊĤ¸¤Æ¤¤¤Ê¤¤¡£
265 (bracket list operators) ¤¬ÊĤ¸¤Æ¤¤¤Ê¤¤¡£
268 ¾È¹ç½ç½ø¤ÎÍ×ÁÇ (collating element) ¤È¤·¤Æ͸ú¤Ç¤Ï¤Ê¤¤¡£
270 (ÌõÃí) ¾È¹ç½ç½ø¤ÎÍ×ÁÇ (collating element) ¤Ë¤Ä¤¤¤Æ¤Ï¡¢
275 ̤ÃΤΥ¥ã¥é¥¯¥¿¥¯¥é¥¹Ì¾¡£
278 ̤ÄêµÁ¥¨¥é¡¼¡£¤³¤ì¤Ï POSIX.2 ¤Ë¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
281 Àµµ¬É½¸½¤¬¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤Ç½ª¤Ã¤Æ¤¤¤ë¡£
283 (ÌõÃí) ÆüËܸì´Ä¶¤Î¾ì¹ç¡¢¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤È¤Ê¤ë¤Ù¤½ê¤¬±ßµ¹æ¤Ç
284 ɽ¼¨¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¤¬¡¢¤³¤ì¤Ïñ¤Ëɽ¼¨¥Õ¥©¥ó¥È¤ÎÌäÂê¤Ç¡¢
285 ÆâÉôŪ¤Ë¤ÏƱ¤¸°ÕÌ£¤Ç¤¢¤ë¡£
290 (parenthesis group operators) ¤¬ÊĤ¸¤Æ¤¤¤Ê¤¤¡£
293 ̵¸ú¤ÊÈÏ°Ï¥ª¥Ú¥ì¡¼¥¿¤Î»ÈÍÑ¡£
294 Î㤨¤Ð¡¢ÈϰϤνªÎ»°ÌÃÖ¤¬³«»Ï°ÌÃÖ¤è¤ê¤âÁ°¤Ë¤¢¤ë¤è¤¦¤Ê¾ì¹ç¡£
297 Àµµ¬É½¸½¤Î¥³¥ó¥Ñ¥¤¥ë¤Ë¡¢64Kb °Ê¾å¤Î¥Ñ¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡¤¬É¬Íס£
298 ¤³¤ì¤Ï POSIX.2 ¤Ë¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
301 regex ¥ë¡¼¥Á¥ó¤¬¥á¥â¥ê¤ò»È¤¤¤Ï¤¿¤·¤Æ¤¤¤ë¡£
304 ¥µ¥Ö¥¨¥¯¥¹¥×¥ì¥Ã¥·¥ç¥ó
306 (subexpression) ¤Ø¤Î̵¸ú¤Ê¸åÊý»²¾È¡£