aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/string/substr/index.html
diff options
context:
space:
mode:
authorMasahiro FUJIMOTO <mfujimot@gmail.com>2021-08-24 13:16:40 +0900
committerGitHub <noreply@github.com>2021-08-24 13:16:40 +0900
commit16f49fa325f1784b3b8bac08ada0000e20139291 (patch)
tree57e9be1e560da9d72bc01675b72961bf1e80e6c0 /files/ja/web/javascript/reference/global_objects/string/substr/index.html
parent9fc238c0d50e2cf6743c885f634974b94e98d88f (diff)
downloadtranslated-content-16f49fa325f1784b3b8bac08ada0000e20139291.tar.gz
translated-content-16f49fa325f1784b3b8bac08ada0000e20139291.tar.bz2
translated-content-16f49fa325f1784b3b8bac08ada0000e20139291.zip
String/substr を更新 (#2093)
- Markdown に変換 - 2021/07/21 時点の英語版に同期
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/string/substr/index.html')
-rw-r--r--files/ja/web/javascript/reference/global_objects/string/substr/index.html118
1 files changed, 0 insertions, 118 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/string/substr/index.html b/files/ja/web/javascript/reference/global_objects/string/substr/index.html
deleted file mode 100644
index 725bc665df..0000000000
--- a/files/ja/web/javascript/reference/global_objects/string/substr/index.html
+++ /dev/null
@@ -1,118 +0,0 @@
----
-title: String.prototype.substr()
-slug: Web/JavaScript/Reference/Global_Objects/String/substr
-tags:
- - Deprecated
- - JavaScript
- - Method
- - Prototype
- - Reference
- - String
- - メソッド
-translation_of: Web/JavaScript/Reference/Global_Objects/String/substr
----
-<div>{{JSRef}}</div>
-
-<p class="seoSummary"><strong><code>substr()</code></strong> メソッドは、文字列の一部を、指定した位置から後方向指定した文字数だけ返します。</p>
-
-<div>{{EmbedInteractiveExample("pages/js/string-substr.html")}}</div>
-
-<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div>
-
-<h2 id="Syntax" name="Syntax">構文</h2>
-
-<pre class="syntaxbox notranslate"><var>str</var>.substr(<var>start</var>[, <var>length</var>])</pre>
-
-<h3 id="Parameters" name="Parameters">引数</h3>
-
-<dl>
- <dt><code><var>start</var></code></dt>
- <dd>返却する部分文字列に含まれる最初の文字の位置です。</dd>
- <dt><code><var>length</var></code></dt>
- <dd>任意です。取り出す文字の数です。</dd>
-</dl>
-
-<h3 id="Return_value" name="Return_value">返値</h3>
-
-<p>指定された文字列の指定された部分が入った新しい文字列です。</p>
-
-<h2 id="Description" name="Description">解説</h2>
-
-<p><code>substr()</code> は、 <code><var>str</var></code> のうち <code><var>length</var></code> 文字分を、 <code><var>start</var></code> の位置から数えて抽出します。</p>
-
-<ul>
- <li><code><var>start</var></code> が正の数である場合、文字列の先頭から数えた位置になります。この値は <code><var>str</var>.length</code> が上限になります。</li>
- <li><code><var>start</var></code> が負の数である場合、文字列の末尾から数えた位置になります。この値は <code>-<var>str</var>.length</code> が下限になります。</li>
- <li>注: Microsoft の JScript では、 <code><var>start</var></code> の引数が負の数であっても文字列の末尾からの位置にはなりません。</li>
- <li><code><var>length</var></code> が省略された場合、 <code>substr()</code> は文字列の末尾までの文字を抽出します。</li>
- <li><code><var>length</var></code> が {{jsxref("undefined")}} である場合、 <code>substr()</code> は文字列の末尾までの文字を抽出します。</li>
- <li><code><var>length</var></code> が負の数である場合、 <code>0</code> として扱われます。</li>
- <li><code><var>start</var></code> および <code><var>length</var></code> において、 {{jsxref("NaN")}} は <code>0</code> として扱われます。</li>
-</ul>
-
-<h2 id="Polyfill" name="Polyfill">ポリフィル</h2>
-
-<p>Microsoft の JScript は start の位置として負の数に対応していません。この機能を使用したい場合は、このバグを回避するために、次の互換コードを使用することができます。</p>
-
-<pre class="brush: js notranslate">// only run when the substr() function is broken
-if ('ab'.substr(-1) != 'b') {
- /**
- * Get the substring of a string
- * @param {integer} start where to start the substring
- * @param {integer} length how many characters to return
- * @return {string}
- */
- String.prototype.substr = function(substr) {
- return function(start, length) {
- // call the original method
- return substr.call(this,
- // did we get a negative start, calculate how much it is from the beginning of the string
- // adjust the start parameter for negative value
- start &lt; 0 ? this.length + start : start,
- length)
- }
- }(String.prototype.substr);
-}
-</pre>
-
-<h2 id="Examples" name="Examples">例</h2>
-
-<h3 id="Using_substr" name="Using_substr">substr() の使用</h3>
-
-<pre class="brush: js notranslate">var aString = 'Mozilla';
-
-console.log(aString.substr(0, 1)); // 'M'
-console.log(aString.substr(1, 0)); // ''
-console.log(aString.substr(-1, 1)); // 'a'
-console.log(aString.substr(1, -1)); // ''
-console.log(aString.substr(-3)); // 'lla'
-console.log(aString.substr(1)); // 'ozilla'
-console.log(aString.substr(-20, 2)); // 'Mo'
-console.log(aString.substr(20, 2)); // ''
-</pre>
-
-<h2 id="Specifications" name="Specifications">仕様書</h2>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">仕様書</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-string.prototype.substr', 'String.prototype.substr')}}</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
-
-<p>{{Compat("javascript.builtins.String.substr")}}</p>
-
-<h2 id="See_also" name="See_also">関連情報</h2>
-
-<ul>
- <li>{{jsxref("String.prototype.slice()")}}</li>
- <li>{{jsxref("String.prototype.substring()")}}</li>
-</ul>