aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files/ja/web/javascript/reference/global_objects/regexp/hasindices/index.md70
-rw-r--r--files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.html87
-rw-r--r--files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.md74
3 files changed, 144 insertions, 87 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/regexp/hasindices/index.md b/files/ja/web/javascript/reference/global_objects/regexp/hasindices/index.md
new file mode 100644
index 0000000000..6b8788a480
--- /dev/null
+++ b/files/ja/web/javascript/reference/global_objects/regexp/hasindices/index.md
@@ -0,0 +1,70 @@
+---
+title: RegExp.prototype.hasIndices
+slug: Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices
+tags:
+ - Draft
+ - JavaScript
+ - Property
+ - Prototype
+ - Reference
+ - RegExp
+ - Regular Expressions
+browser-compat: javascript.builtins.RegExp.hasIndices
+translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices
+---
+{{JSRef}}
+
+**`hasIndices`** プロパティは、その正規表現で "`d`" フラグが使用されたかどうかを示します。 `hasIndices` はそれぞれの正規表現インスタンスの読み取り専用プロパティです。
+
+{{EmbedInteractiveExample("pages/js/regexp-prototype-hasindices.html")}}
+
+{{JS_Property_Attributes(0, 0, 1)}}
+
+## 解説
+
+`hasIndices` の値は論理型であり、 "`d`" フラグが使用された場合は `true` になります。それ以外の場合は `false` になります。 "`d`" フラグは正規表現による一致の結果に、各キャプチャグループの部分文字列の開始と終了の位置を含めることを示します。
+
+このプロパティを直接変更することはできません。
+
+## 例
+
+### `hasIndices` の使用
+
+```js
+const str1 = 'foo bar foo';
+
+const regex1 = new RegExp('foo', 'gd');
+
+console.log(regex1.hasIndices); // 出力: true
+
+console.log(regex1.exec(str1).indices[0]); // 出力: Array [0, 3]
+console.log(regex1.exec(str1).indices[0]); // 出力: Array [8, 11]
+
+const str2 = 'foo bar foo';
+
+const regex2 = new RegExp('foo');
+
+console.log(regex2.hasIndices); // 出力: false
+
+console.log(regex2.exec(str2).indices); // 出力: undefined
+```
+
+## 仕様書
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
+
+## 関連情報
+
+- {{JSxRef("RegExp.lastIndex")}}
+- {{JSxRef("RegExp.prototype.exec()")}}
+- {{JSxRef("RegExp.prototype.dotAll")}}
+- {{JSxRef("RegExp.prototype.global")}}
+- {{JSxRef("RegExp.prototype.ignoreCase")}}
+- {{JSxRef("RegExp.prototype.multiline")}}
+- {{JSxRef("RegExp.prototype.source")}}
+- {{JSxRef("RegExp.prototype.sticky")}}
+- {{JSxRef("RegExp.prototype.unicode")}}
diff --git a/files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.html b/files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.html
deleted file mode 100644
index ce94abd766..0000000000
--- a/files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.html
+++ /dev/null
@@ -1,87 +0,0 @@
----
-title: RegExp.lastIndex
-slug: Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
-tags:
- - JavaScript
- - Property
- - Reference
- - RegExp
- - Regular Expression
-translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
----
-<div>{{JSRef}}</div>
-
-<p><strong><code>lastIndex</code></strong> は正規表現インスタンスの読み書き可能なプロパティで、次の一致を開始する位置を指定します。</p>
-
-<div>{{EmbedInteractiveExample("pages/js/regexp-lastindex.html")}}</div>
-
-<div>{{js_property_attributes(1, 0, 0)}}</div>
-
-<h2 id="Syntax" name="Syntax">構文</h2>
-
-<pre class="syntaxbox"><code><var>regExpObj</var>.lastIndex</code></pre>
-
-<h2 id="Description" name="Description">解説</h2>
-
-<p>このプロパティは、正規表現インスタンスがグローバル検索を示すために <code>g</code> フラグを使用した場合、または粘着的検索を示すために <code>y</code> フラグを使用した場合にのみ設定されます。以下の規則が適用されます。</p>
-
-<ul>
- <li><code>lastIndex</code> が文字列の長さよりも大きければ、 {{jsxref("RegExp.prototype.test()", "test()")}} および {{jsxref("RegExp.prototype.exec()", "exec()")}} は失敗し、<code>lastIndex</code> は 0 にセットされます。</li>
- <li><code>lastIndex</code> が文字列の長さ以下で、かつ正規表現が空文字列に一致する場合には、正規表現は <code>lastIndex</code> から始まる入力に一致します。</li>
- <li><code>lastIndex</code> が文字列の長さと等しく、かつ、正規表現が空文字列に一致しない場合、正規表現は入力に一致せず、 <code>lastIndex</code> は 0 にリセットされます。</li>
- <li>それ以外の場合は、 <code>lastIndex</code> は直近の一致に続く次の位置に設定されます。</li>
-</ul>
-
-<h2 id="Examples" name="Examples">例</h2>
-
-<h3 id="lastIndex_の使用">lastIndex の使用</h3>
-
-<p>例えば、以下の連続した処理を考えてみてください。:</p>
-
-<pre class="brush: js">var re = /(hi)?/g;
-</pre>
-
-<p>空文字列に一致します。</p>
-
-<pre class="brush: js">console.log(re.exec('hi'));
-console.log(re.lastIndex);
-</pre>
-
-<p><code>lastIndex</code> が 2 になり<code>["hi", "hi"]</code> が返ります。</p>
-
-<pre class="brush: js">console.log(re.exec('hi'));
-console.log(re.lastIndex);
-</pre>
-
-<p>ゼロ番目の要素が一致した文字列なので、 <code>["", undefined]</code> という空配列が返ります。この場合、 <code>lastIndex</code> が 2 であったときに (そして 2 のままである)、 <code>hi</code> の長さが 2 であるので、空文字列になります。</p>
-
-<h2 id="Specifications" name="Specifications">仕様書</h2>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">仕様書</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-properties-of-regexp-instances', 'RegExp.lastIndex')}}</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
-
-<div>
-<p>{{Compat("javascript.builtins.RegExp.lastIndex")}}</p>
-</div>
-
-<h2 id="See_also" name="See_also">関連情報</h2>
-
-<ul>
- <li>{{jsxref("RegExp.prototype.ignoreCase")}}</li>
- <li>{{jsxref("RegExp.prototype.global")}}</li>
- <li>{{jsxref("RegExp.prototype.multiline")}}</li>
- <li>{{jsxref("RegExp.prototype.source")}}</li>
- <li>{{jsxref("RegExp.prototype.sticky")}}</li>
-</ul>
diff --git a/files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.md b/files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.md
new file mode 100644
index 0000000000..5416149a87
--- /dev/null
+++ b/files/ja/web/javascript/reference/global_objects/regexp/lastindex/index.md
@@ -0,0 +1,74 @@
+---
+title: 'RegExp: lastIndex'
+slug: Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
+tags:
+ - JavaScript
+ - Property
+ - Reference
+ - RegExp
+ - 正規表現
+browser-compat: javascript.builtins.RegExp.lastIndex
+translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
+---
+{{JSRef}}
+
+**`lastIndex`** は {{jsXref("RegExp")}} インスタンスの読み書き可能なプロパティで、次の一致を開始する位置を指定します。
+
+なお、 `lastIndex` は {{jsXref("RegExp")}} プロトタイプのプロパティではありませんが、 {{jsXref("RegExp")}} インスタンスからのみ公開されます。
+
+{{EmbedInteractiveExample("pages/js/regexp-lastindex.html")}}{{js_property_attributes(1, 0, 0)}}
+
+## 解説
+
+このプロパティは、正規表現インスタンスがグローバル検索を示すために `g` フラグを使用した場合、または粘着的検索を示すために `y` フラグを使用した場合にのみ設定されます。 {{jsxref("RegExp.prototype.test()", "test()")}} および {{jsxref("RegExp.prototype.exec()", "exec()")}} が指定された入力に対して呼び出されたとき、以下の規則が適用されます。
+
+- `lastIndex` が入力の長さよりも大きい場合、 `exec()` または `test()` は一致するものを見つけられず、 `lastIndex` は 0 に設定されます。
+- `lastIndex` が入力の長さ以下であった場合、 `exec()` または `test()` は `lastIndex` から一致するものを探そうとします。
+
+ - `exec()` または `test()` が一致するものを見つけた場合 `lastIndex` は入力の中の一致する文字列の末尾の位置に設定されます。
+ - `exec()` または `test()` が一致するものを見つけられなかった場合、 `lastIndex` は 0 に設定されます。
+
+## 例
+
+### lastIndex の使用
+
+例えば、以下の一連の処理を考えてみてください。
+
+```js
+var re = /(hi)?/g;
+```
+
+空文字列に一致します。
+
+```js
+console.log(re.exec('hi'));
+console.log(re.lastIndex);
+```
+
+`["hi", "hi"]` を返し、 `lastIndex` は 2 になります。
+
+```js
+console.log(re.exec('hi'));
+console.log(re.lastIndex);
+```
+
+返値は `["", undefined]` で、 0 番目の要素が一致文字列となる空の配列です。この場合、 `lastIndex` が 2 (現在も 2) であり、`hi` の長さが 2 であるため、空の文字列となります。
+
+## 仕様書
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
+
+## 関連情報
+
+- {{JSxRef("RegExp.prototype.dotAll")}}
+- {{JSxRef("RegExp.prototype.global")}}
+- {{JSxRef("RegExp.prototype.hasIndices")}}
+- {{JSxRef("RegExp.prototype.ignoreCase")}}
+- {{JSxRef("RegExp.prototype.multiline")}}
+- {{JSxRef("RegExp.prototype.source")}}
+- {{JSxRef("RegExp.prototype.sticky")}}
+- {{JSxRef("RegExp.prototype.unicode")}}