[Groonga-commit] pgroonga/pgroonga.github.io at 8a1816b [master] Complete regular expression document

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jan 3 17:15:05 JST 2016


Kouhei Sutou	2016-01-03 17:15:05 +0900 (Sun, 03 Jan 2016)

  New Revision: 8a1816b709e0354d85d5739af1f0f5be175432b9
  https://github.com/pgroonga/pgroonga.github.io/commit/8a1816b709e0354d85d5739af1f0f5be175432b9

  Message:
    Complete regular expression document

  Added files:
    _po/ja/reference/operators/regexp.po
    ja/reference/operators/regexp.md
  Modified files:
    reference/operators/regexp.md

  Added: _po/ja/reference/operators/regexp.po (+267 -0) 100644
===================================================================
--- /dev/null
+++ _po/ja/reference/operators/regexp.po    2016-01-03 17:15:05 +0900 (7b08e0e)
@@ -0,0 +1,267 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: 2016-01-03 17:14+0900\n"
+"Language: ja\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+msgid ""
+"---\n"
+"title: \"@~ operator\"\n"
+"layout: en\n"
+"---"
+msgstr ""
+"---\n"
+"title: \"@~演算子\"\n"
+"layout: ja\n"
+"---"
+
+msgid "# `@~` operator"
+msgstr "# `@~`演算子"
+
+msgid "## Summary"
+msgstr "## 概要"
+
+msgid "`@~` operator performs regular expression search."
+msgstr "`@~`演算子は正規表現検索をします。"
+
+msgid "PostgreSQL provides the following built-in regular expression operators:"
+msgstr "PostgreSQLは次のような組み込みの正規表現演算子を提供しています。"
+
+msgid ""
+"  * [`SIMILAR TO`](http://www.postgresql.org/docs/{{ site.postgresql_short_ver"
+"sion }}/static/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP)"
+msgstr ""
+"  * [`SIMILAR TO`](http://www.postgresql.jp/document/{{ site.postgresql_short_"
+"version }}/html/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP)"
+
+msgid ""
+"  * [POSIX Regular Expression](http://www.postgresql.org/docs/{{ site.postgres"
+"ql_short_version }}/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP)"
+msgstr ""
+"  * [POSIX正規表現](http://www.postgresql.jp/document/{{ site.postgresql_short_ver"
+"sion }}/html/functions-matching.html#FUNCTIONS-POSIX-REGEXP)"
+
+msgid ""
+"`SIMILAR TO` is based on SQL standard. \"POSIX Regular Expression\" is based on "
+"POSIX. They use different regular expression syntax."
+msgstr ""
+"`SIMILAR TO`はSQL標準をベースにしています。「POSIX正規表現」はPOSIXをベースにしています。これらはそれぞれ違う正規表現の構文を使いま"
+"す。"
+
+msgid ""
+"PGroonga's `@~` operator uses another regular expression syntax. `@~` uses syn"
+"tax that is used in [Ruby](https://www.ruby-lang.org/). Because PGroonga uses "
+"the same regular expression engine that is used in Ruby. It's [Onigmo](https:/"
+"/github.com/k-takata/Onigmo). See [Onigmo document](https://github.com/k-takat"
+"a/Onigmo/blob/master/doc/RE) for full syntax definition."
+msgstr ""
+"PGroongaの`@~`演算子はさらに別の正規表現の構文を使います。`@~`は[Ruby](https://www.ruby-lang.org/ja/)で"
+"使われている構文を使います。なぜなら、PGroongaはRubyが使っている正規表現エンジンと同じエンジンを使っているからです。そのエンジンは[Onigmo"
+"](https://github.com/k-takata/Onigmo)です。完全な構文定義は[Onigmoのドキュメント](https://github"
+".com/k-takata/Onigmo/blob/master/doc/RE.ja)を参照してください。"
+
+msgid ""
+"PGroonga's `@~` operator normalizes target text before matching. It's similar "
+"to `~*` operator in \"POSIX Regular Expression\". It performs case insensitive m"
+"atch."
+msgstr ""
+"PGroongaの`@~`演算子はマッチ前に対象文字列を正規化します。これは「POSIX正規表現」の`~*`演算子と似ています。`~*`演算子は大文字小文字"
+"の違いを無視してマッチしているかを判断します。"
+
+msgid ""
+"Normalization is different from case insensitive. Normally, normalization is m"
+"ore powerful."
+msgstr "正規化と大文字小文字の違いを無視することは違います。通常、正規化のほうがよりパワフルです。"
+
+msgid ""
+"Example1: All of \"`A`\", \"`a`\", \"`A`\" (U+FF21 FULLWIDTH LATIN CAPITAL LETTER A)"
+", \"`a`\" (U+FF41 FULLWIDTH LATIN SMALL LETTER A) are normalized to \"`a`\"."
+msgstr ""
+"例1:「`A`」も「`a`」も「`A`」(U+FF21 FULLWIDTH LATIN CAPITAL LETTER A)も「`a`」(U+FF41 FUL"
+"LWIDTH LATIN SMALL LETTER A)もすべて「`a`」に正規化されます。"
+
+msgid ""
+"Example2: Both of full-width Katakana and half-width Katakana are normalized t"
+"o full-width Katakana. For example, both of \"`ア`\" (U+30A2 KATAKANA LETTER A) a"
+"nd \"`ア`\" (U+FF71 HALFWIDTH KATAKANA LETTER A) are normalized to \"`ア`\" (U+30A2 "
+"KATAKANA LETTER A)."
+msgstr ""
+"例2:いわゆる全角カタカナも半角カタカナもどちらも全角カタカナに正規化されます。たとえば、「`ア`」(U+30A2 KATAKANA LETTER A)も「"
+"`ア`」(U+FF71 HALFWIDTH KATAKANA LETTER A)もどちらも「`ア`」(U+30A2 KATAKANA LETTER A)に正"
+"規化されます。"
+
+msgid ""
+"Note that `@~` operator doesn't normalize regular expression pattern. It only "
+"normalizes target text. It means that you must use normalized characters in re"
+"gular expression pattern."
+msgstr ""
+"`@~`演算子は正規表現パターンは正規化しないことに注意してください。マッチ対象のテキストだけを正規化します。これは正規表現パターンのなかでは正規化された文"
+"字だけを使うべきだということです。"
+
+msgid ""
+"For example, you must not use \"`Groonga`\" as pattern. You must use \"`groonga`\""
+" as pattern. Because \"`G`\" is normalized to \"`g`\"."
+msgstr ""
+"たとえば、パターンに「`Groonga`」を使ってはいけません。そうではなく、「`groonga`」を使うべきです。なぜなら、「`G`」は「`g`」に正規化"
+"されるからです。"
+
+msgid "## Syntax"
+msgstr "## 構文"
+
+msgid ""
+"```sql\n"
+"column @~ regular_expression\n"
+"```"
+msgstr ""
+
+msgid "`column` is a column to be searched."
+msgstr "`column`は検索対象のカラムです。"
+
+msgid "`regular_expression` is a regular expression to be used as pattern."
+msgstr "`regular_expression`はパターンとして使う正規表現です。"
+
+msgid ""
+"Types of `column` and `regular_expression` must be the same. Here are availabl"
+"e types:"
+msgstr "`column`と`regular_expression`の型は同じでなければいけません。利用可能な型は次の通りです。"
+
+msgid "  * `text`"
+msgstr ""
+
+msgid "  * `varchar`"
+msgstr ""
+
+msgid ""
+"If `column` value is matched against `regular_expression` pattern, the express"
+"ion returns `true`."
+msgstr "`column`の値が`regular_expression`パターンにマッチしたら、その式は`true`を返します。"
+
+msgid "## Usage"
+msgstr "## 使い方"
+
+msgid "Here are sample schema for examples:"
+msgstr "以下は例で使うサンプルスキーマです。"
+
+msgid ""
+"```sql\n"
+"CREATE TABLE memos (\n"
+"  id integer,\n"
+"  content text\n"
+");"
+msgstr ""
+
+msgid ""
+"CREATE INDEX pgroonga_content_index ON memos\n"
+"  USING pgroonga (content pgroonga.text_regexp_ops);\n"
+"```"
+msgstr ""
+
+msgid ""
+"You must specify operator class to perform regular expression search by index."
+" Here are available operator classes:"
+msgstr "インデックスを用いて正規表現検索を実行するにはオペレータークラスを指定しなければいけません。利用可能なオペレータークラスは次の通りです。"
+
+msgid ""
+"  * `pgroonga.text_regexp_ops`: It's the operator class for `text` type column"
+"."
+msgstr "  * `pgroonga.text_regexp_ops`:`text`型のカラム用のオペレータークラス。"
+
+msgid ""
+"  * `pgroonga.varchar_regexp_ops`: It's the operator class for `varchar` type "
+"column."
+msgstr "  * `pgroonga.varchar_regexp_ops`:`varchar`型のカラム用のオペレータークラス。"
+
+msgid ""
+"In this example, `pgroonga.text_regexp_ops` is used. Because `content` column "
+"is a `text` type column."
+msgstr "この例では`pgroonga.text_regexp_ops`を使っています。なぜなら`content`カラムは`text`型のカラムだからです。"
+
+msgid "Here are data for examples:"
+msgstr "以下は例で使うデータです。"
+
+msgid ""
+"```sql\n"
+"INSERT INTO memos VALUES (1, 'PostgreSQL is a relational database management s"
+"ystem.');\n"
+"INSERT INTO memos VALUES (2, 'Groonga is a fast full text search engine that s"
+"upports all languages.');\n"
+"INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Gro"
+"onga as index.');\n"
+"INSERT INTO memos VALUES (4, 'There is groonga command.');\n"
+"```"
+msgstr ""
+"```sql\n"
+"INSERT INTO memos VALUES (1, 'PostgreSQLはリレーショナル・データベース管理システムです。');\n"
+"INSERT INTO memos VALUES (2, 'Groongaは日本語対応の高速な全文検索エンジンです。');\n"
+"INSERT INTO memos VALUES (3, 'PGroongaはインデックスとしてGroongaを使うためのPostgreSQLの拡張機能です"
+"。');\n"
+"INSERT INTO memos VALUES (4, 'groongaコマンドがあります。');\n"
+"```"
+
+msgid "You can perform regular expression search by `@~` operator:"
+msgstr "`@~`演算子を使うと正規表現検索を実行できます。"
+
+msgid ""
+"```sql\n"
+"SELECT * FROM memos WHERE content @~ '\\Apostgresql';\n"
+"--  id |                        content                         \n"
+"-- ----+--------------------------------------------------------\n"
+"--   1 | PostgreSQL is a relational database management system.\n"
+"-- (1 row)\n"
+"```"
+msgstr ""
+"```sql\n"
+"SELECT * FROM memos WHERE content @~ '\\Apostgresql';\n"
+"--  id |                          content                           \n"
+"-- ----+------------------------------------------------------------\n"
+"--   1 | PostgreSQLはリレーショナル・データベース管理システムです。\n"
+"-- (1 row)\n"
+"```"
+
+msgid ""
+"\"`\\A`\" in \"`\\Apostgresql`\" is a special notation in Ruby regular expression sy"
+"ntax. It means that the beginning of text. The pattern means that \"`postgresql"
+"`\" must be appeared in the beginning of text."
+msgstr ""
+"「`\\Apostgresql`」の中の「`\\A`」はRubyの正規表現構文では特別な記法です。これはテキストの最初という意味です。つまり、このパターンは「`"
+"postgresql`」がテキストの最初に現れること、という意味です。"
+
+msgid ""
+"Why is \"`PostgreSQL is a ...`\" record matched? Remember that `@~` operator nor"
+"malizes target text before matching. It means that \"`PostgreSQL is a ...`\" tex"
+"t is normalized to \"`postgresql is a ...`\" text before matching. The normalize"
+"d text is started with \"`postgresql`\". So \"`\\Apostgresql`\" regular expression "
+"matches to the record."
+msgstr ""
+"どうして「`PostgreSQLは..`」レコードがマッチしているのでしょうか?`@~`演算しはマッチ前にマッチ対象のテキストを正規化することを思い出してく"
+"ださい。つまり、「`PostgreSQLは...`」テキストはマッチ前に「`postgresqlは...`」と正規化されるということです。正規化されたテキス"
+"トは「`postgresql`」で始まっています。そのため、「`\\Apostgresql`」正規表現はこのレコードにマッチします。"
+
+msgid ""
+"\"`PGroonga is a PostgreSQL ...`\" record isn't matched. It includes \"`postgresq"
+"l`\" in normalized text but \"`postgresql`\" isn't appeared at the beginning of t"
+"ext. So it's not matched."
+msgstr ""
+"\"`PGroongaはPostgreSQLの ...`\"レコードはマッチしません。このレコードは正規化後のテキストに「`postgresql`」を含んでいま"
+"すが、「`postgresql`」はテキストの先頭には現れていません。そのためマッチしません。"
+
+msgid "## See also"
+msgstr "## 参考"
+
+msgid ""
+"  * [Onigmo's regular expression syntax document](https://github.com/k-takata/"
+"Onigmo/blob/master/doc/RE)"
+msgstr ""
+"  * [Onigmoの正規表現構文のドキュメント](https://github.com/k-takata/Onigmo/blob/master/doc/"
+"RE.ja)"
+
+msgid ""
+"  * [Groonga's regular expression support document](http://groonga.org/docs/re"
+"ference/regular_expression.html)"
+msgstr ""
+"  * [Groongaの正規表現サポートに関するドキュメント](http://groonga.org/ja/docs/reference/regular_"
+"expression.html)"

  Added: ja/reference/operators/regexp.md (+103 -0) 100644
===================================================================
--- /dev/null
+++ ja/reference/operators/regexp.md    2016-01-03 17:15:05 +0900 (f39fdaa)
@@ -0,0 +1,103 @@
+---
+title: "@~演算子"
+layout: ja
+---
+
+# `@~`演算子
+
+## 概要
+
+`@~`演算子は正規表現検索をします。
+
+PostgreSQLは次のような組み込みの正規表現演算子を提供しています。
+
+  * [`SIMILAR TO`](http://www.postgresql.jp/document/{{ site.postgresql_short_version }}/html/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP)
+
+  * [POSIX正規表現](http://www.postgresql.jp/document/{{ site.postgresql_short_version }}/html/functions-matching.html#FUNCTIONS-POSIX-REGEXP)
+
+`SIMILAR TO`はSQL標準をベースにしています。「POSIX正規表現」はPOSIXをベースにしています。これらはそれぞれ違う正規表現の構文を使います。
+
+PGroongaの`@~`演算子はさらに別の正規表現の構文を使います。`@~`は[Ruby](https://www.ruby-lang.org/ja/)で使われている構文を使います。なぜなら、PGroongaはRubyが使っている正規表現エンジンと同じエンジンを使っているからです。そのエンジンは[Onigmo](https://github.com/k-takata/Onigmo)です。完全な構文定義は[Onigmoのドキュメント](https://github.com/k-takata/Onigmo/blob/master/doc/RE.ja)を参照してください。
+
+PGroongaの`@~`演算子はマッチ前に対象文字列を正規化します。これは「POSIX正規表現」の`~*`演算子と似ています。`~*`演算子は大文字小文字の違いを無視してマッチしているかを判断します。
+
+正規化と大文字小文字の違いを無視することは違います。通常、正規化のほうがよりパワフルです。
+
+例1:「`A`」も「`a`」も「`A`」(U+FF21 FULLWIDTH LATIN CAPITAL LETTER A)も「`a`」(U+FF41 FULLWIDTH LATIN SMALL LETTER A)もすべて「`a`」に正規化されます。
+
+例2:いわゆる全角カタカナも半角カタカナもどちらも全角カタカナに正規化されます。たとえば、「`ア`」(U+30A2 KATAKANA LETTER A)も「`ア`」(U+FF71 HALFWIDTH KATAKANA LETTER A)もどちらも「`ア`」(U+30A2 KATAKANA LETTER A)に正規化されます。
+
+`@~`演算子は正規表現パターンは正規化しないことに注意してください。マッチ対象のテキストだけを正規化します。これは正規表現パターンのなかでは正規化された文字だけを使うべきだということです。
+
+たとえば、パターンに「`Groonga`」を使ってはいけません。そうではなく、「`groonga`」を使うべきです。なぜなら、「`G`」は「`g`」に正規化されるからです。
+
+## 構文
+
+```sql
+column @~ regular_expression
+```
+
+`column`は検索対象のカラムです。
+
+`regular_expression`はパターンとして使う正規表現です。
+
+`column`と`regular_expression`の型は同じでなければいけません。利用可能な型は次の通りです。
+
+  * `text`
+
+  * `varchar`
+
+`column`の値が`regular_expression`パターンにマッチしたら、その式は`true`を返します。
+
+## 使い方
+
+以下は例で使うサンプルスキーマです。
+
+```sql
+CREATE TABLE memos (
+  id integer,
+  content text
+);
+
+CREATE INDEX pgroonga_content_index ON memos
+  USING pgroonga (content pgroonga.text_regexp_ops);
+```
+
+インデックスを用いて正規表現検索を実行するにはオペレータークラスを指定しなければいけません。利用可能なオペレータークラスは次の通りです。
+
+  * `pgroonga.text_regexp_ops`:`text`型のカラム用のオペレータークラス。
+
+  * `pgroonga.varchar_regexp_ops`:`varchar`型のカラム用のオペレータークラス。
+
+この例では`pgroonga.text_regexp_ops`を使っています。なぜなら`content`カラムは`text`型のカラムだからです。
+
+以下は例で使うデータです。
+
+```sql
+INSERT INTO memos VALUES (1, 'PostgreSQLはリレーショナル・データベース管理システムです。');
+INSERT INTO memos VALUES (2, 'Groongaは日本語対応の高速な全文検索エンジンです。');
+INSERT INTO memos VALUES (3, 'PGroongaはインデックスとしてGroongaを使うためのPostgreSQLの拡張機能です。');
+INSERT INTO memos VALUES (4, 'groongaコマンドがあります。');
+```
+
+`@~`演算子を使うと正規表現検索を実行できます。
+
+```sql
+SELECT * FROM memos WHERE content @~ '\Apostgresql';
+--  id |                          content                           
+-- ----+------------------------------------------------------------
+--   1 | PostgreSQLはリレーショナル・データベース管理システムです。
+-- (1 row)
+```
+
+「`\Apostgresql`」の中の「`\A`」はRubyの正規表現構文では特別な記法です。これはテキストの最初という意味です。つまり、このパターンは「`postgresql`」がテキストの最初に現れること、という意味です。
+
+どうして「`PostgreSQLは..`」レコードがマッチしているのでしょうか?`@~`演算しはマッチ前にマッチ対象のテキストを正規化することを思い出してください。つまり、「`PostgreSQLは...`」テキストはマッチ前に「`postgresqlは...`」と正規化されるということです。正規化されたテキストは「`postgresql`」で始まっています。そのため、「`\Apostgresql`」正規表現はこのレコードにマッチします。
+
+"`PGroongaはPostgreSQLの ...`"レコードはマッチしません。このレコードは正規化後のテキストに「`postgresql`」を含んでいますが、「`postgresql`」はテキストの先頭には現れていません。そのためマッチしません。
+
+## 参考
+
+  * [Onigmoの正規表現構文のドキュメント](https://github.com/k-takata/Onigmo/blob/master/doc/RE.ja)
+
+  * [Groongaの正規表現サポートに関するドキュメント](http://groonga.org/ja/docs/reference/regular_expression.html)

  Modified: reference/operators/regexp.md (+20 -10)
===================================================================
--- reference/operators/regexp.md    2016-01-03 16:23:03 +0900 (7c483eb)
+++ reference/operators/regexp.md    2016-01-03 17:15:05 +0900 (0112932)
@@ -23,13 +23,13 @@ PGroonga's `@~` operator normalizes target text before matching. It's similar to
 
 Normalization is different from case insensitive. Normally, normalization is more powerful.
 
-Example1: All of "A", "a", "A" (U+FF21 FULLWIDTH LATIN CAPITAL LETTER A), "a" (U+FF41 FULLWIDTH LATIN SMALL LETTER A) are normalized to "a".
+Example1: All of "`A`", "`a`", "`A`" (U+FF21 FULLWIDTH LATIN CAPITAL LETTER A), "`a`" (U+FF41 FULLWIDTH LATIN SMALL LETTER A) are normalized to "`a`".
 
-Example2: Both of full-width Hiragana and half-width Katakana are normalized to full-width Katakana. For example, both of "ア" (U+30A2 KATAKANA LETTER A) and "ア" (U+FF71 HALFWIDTH KATAKANA LETTER A) are normalized to "ア" (U+30A2 KATAKANA LETTER A.
+Example2: Both of full-width Katakana and half-width Katakana are normalized to full-width Katakana. For example, both of "`ア`" (U+30A2 KATAKANA LETTER A) and "`ア`" (U+FF71 HALFWIDTH KATAKANA LETTER A) are normalized to "`ア`" (U+30A2 KATAKANA LETTER A).
 
 Note that `@~` operator doesn't normalize regular expression pattern. It only normalizes target text. It means that you must use normalized characters in regular expression pattern.
 
-For example, you must not use `Groonga` as pattern. You must use `groonga` as pattern. Because "G" is normalized to "g".
+For example, you must not use "`Groonga`" as pattern. You must use "`groonga`" as pattern. Because "`G`" is normalized to "`g`".
 
 ## Syntax
 
@@ -47,6 +47,8 @@ Types of `column` and `regular_expression` must be the same. Here are available
 
   * `varchar`
 
+If `column` value is matched against `regular_expression` pattern, the expression returns `true`.
+
 ## Usage
 
 Here are sample schema for examples:
@@ -67,7 +69,7 @@ You must specify operator class to perform regular expression search by index. H
 
   * `pgroonga.varchar_regexp_ops`: It's the operator class for `varchar` type column.
 
-In this example, we use `pgroonga.text_regexp_ops`. Because `content` column is a `text` type column.
+In this example, `pgroonga.text_regexp_ops` is used. Because `content` column is a `text` type column.
 
 Here are data for examples:
 
@@ -81,13 +83,21 @@ INSERT INTO memos VALUES (4, 'There is groonga command.');
 You can perform regular expression search by `@~` operator:
 
 ```sql
-SELECT * FROM memos WHERE content @~ '\Agroonga';
---  id |                                content                                 
--- ----+------------------------------------------------------------------------
---   2 | Groonga is a fast full text search engine that supports all languages.
+SELECT * FROM memos WHERE content @~ '\Apostgresql';
+--  id |                        content                         
+-- ----+--------------------------------------------------------
+--   1 | PostgreSQL is a relational database management system.
 -- (1 row)
 ```
 
-"`\A`" in "`\Agroonga`" is a special notation in Ruby regular expression syntax. It means that the beginning of text. The pattern means that "`groonga`" must be appeared in the beginning of text.
+"`\A`" in "`\Apostgresql`" is a special notation in Ruby regular expression syntax. It means that the beginning of text. The pattern means that "`postgresql`" must be appeared in the beginning of text.
+
+Why is "`PostgreSQL is a ...`" record matched? Remember that `@~` operator normalizes target text before matching. It means that "`PostgreSQL is a ...`" text is normalized to "`postgresql is a ...`" text before matching. The normalized text is started with "`postgresql`". So "`\Apostgresql`" regular expression matches to the record.
+
+"`PGroonga is a PostgreSQL ...`" record isn't matched. It includes "`postgresql`" in normalized text but "`postgresql`" isn't appeared at the beginning of text. So it's not matched.
+
+## See also
+
+  * [Onigmo's regular expression syntax document](https://github.com/k-takata/Onigmo/blob/master/doc/RE)
 
-TODO
+  * [Groonga's regular expression support document](http://groonga.org/docs/reference/regular_expression.html)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index