移動先 先頭, 前, , 末尾 セクション, 目次.

@paragraphindent 2

Copyright (C) 1992 Free Software Foundation.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the section entitled "GNU General Public License" is included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the section entitled "GNU General Public License" may be included in a translation approved by the Free Software Foundation instead of in the original English.

Overview

正規表現(もしくはパターン)とは、ある文字列の(数学的な) 集合を記述しているテキスト文字列のことである。 ある正規表現rが文字列sマッチするとは、 その文字列srにより定義される集合の中にあるという事である。

Regexライブラリの使用によって以下のことが可能となる。

一部の正規表現は一つの文字列だけ、つまり要素をただ一つしか持たない 集合にマッチする。たとえば`foo'`foo'という文字列に マッチするが、それ以外にはマッチしない。別の正規表現は二つ以上の 文字列、つまり二つ以上の要素を持つ集合にマッチする。 たとえば`f*'は任意の数(0個を含む)の`f'がある文字列 (の集合)にマッチする。 見ての通り、キャラクタには正規表現の中で自分自身にマッチするもの (`f'のように)と、しないもの(`*'のように)がある。 自分自身にマッチしないものは、多くの異なった文字列を記述する パターンを特定するのを可能にする。

Regexライブラリの関数を使って正規表現のマッチングなり検索をするために まず初めにRegexのパターンコンパイル関数を使って(パターンを)コンパイル しなければならない。コンパイルされたパターンはライブラリ関数に よって使われる内部フォーマットに変換された正規表現である。 一度パターンをコンパイルすれば、それを使って何回でもマッチングや 検索を行うことができる。

Regexライブラリは二つのソースファイル`regex.h'`regex.c' から構成される。 Regexは正規表現を扱う三つのグループを持つ。その一つはGNUグループで 非常にパワフルではあるが他の二つのグループ、POSIXとバークレイUNIX とは全然互換性がない。このグループのインターフェースは特にGNUのために デザインされた。これ以外の二つのグループの正規表現関数のインターフェースは 同じである。

この章では(Emacsのような)プログラムのユーザーではなく、Regexを 使うプログラマを念頭において記述する。 Regexライブラリについては完全に記述するけれども、特定のプログラムを 理解するために正規表現の書き方を記述するようなことはしない。


移動先 先頭, 前, , 末尾 セクション, 目次.