# 文字列の一部を取り出す(String.substr) > 現在の文字列の部分文字列を返します。 - カテゴリ:テキスト(text) - ブロック:文字列 "" の 0 番目から 0 文字 - URL:https://makecode.minecraft-okinawa.com/reference/text/substr/ - 公式データ取得日:2026-11-13 - 動作確認:確認待ち ## JavaScript ```javascript "".substr(0, 0) ``` ## Python ```python "".substr(0, 0) ``` ## 引数 | 名前 | 値 | 意味 | |---|---|---| | start | 数値 | 最初の文字の位置。負の値を指定すると、末尾から数えることができます。たとえば:0 | | length | 数値 | 抽出する文字数 | ## 使用例 ### You could make a new string that just has the word "there" from a bigger string that says "Hello there!!!". To do that, the substring is copied from the character position of 6 in the first string and 5 characters are copied. It's done like this: ```javascript let there = "Hello there!!!".substr(6, 5) ``` ```python there = "Hello there!!!".substr(6, 5) ``` ### If you want to have the substring copy to the end of the first string, you just use a starting position and either don't use the length parameter or set it to 0. This will copy all of the first string beginning at position 6. The substring will say "there!!!" in this case. ```javascript let there = "Hello there!!!".substr(6) // - or - let there = "Hello there!!!".substr(6, 0) ``` ```python there = "Hello there!!!".substr(6) # - or - there2 = "Hello there!!!".substr(6, 0) ``` ### Copy the nouns from the sentence into two smaller strings. ```javascript let sentence = "The mountains have snow" let mountains = sentence.substr(4, 9) let snow = sentence.substr(19) ``` ```python sentence = "The mountains have snow" mountains = sentence.substr(4, 9) snow = sentence.substr(19) ``` ## 出典 - [MakeCode for Minecraft 公式リファレンス(String.substr)](https://minecraft.makecode.com/reference/text/substr) 執筆:鈴木孝昌(現役プロジェクトマネージャー/マイクラカップ指導者)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)