4. テキスト検索の一般的手法
例として、次のような英文から「動詞過去形+the+名詞句」をできるだけ多く
抽出することを考える。
Sammy plucked the guitar, while Eddie played the piano.
? 通常検索(非正規表現検索)
ed theで検索
Sammy plucked the guitar, while Eddie played the piano.
? 正規表現検索
/?s.*?ed?sthe?s.+?[?s?.,]/ で検索
Sammy plucked the guitar, while Eddie played the piano.
4 同志社ことばの会年次大会 2008年2月11日
5. 正規表現とは
? 正規表現(regular expressions)
形式言語理論に起源を持つ、文字列集合を定義するためのメタ言語。プ
ログラミング言語やテキストエディタにおけるパターンマッチング用の表記
法として広く用いられている。
Sammy plucked the guitar, while Eddie played the piano.
_ + ...ed + _ + the + _ + ... + (_ | . | ,)
正規表現 ?s.+?ed?sthe?s.+?[?s?.,]
5 同志社ことばの会年次大会 2008年2月11日