文字列を区切って配列にする String.split

テキスト公式データ取得日:2026年11月13日動作確認待ち

ひとことで言うと

区切り文字で文字列を分割する。

ブロックとコード

ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。

引数(ひきすう)

引数とは、ブロックの中で自分で選んだり入力したりする部分のことです。

名前選べる値意味
separator文字列@param limit
limit数値

使用例

If a string contains a list of animals and those animal names each end with a comma, that comma can be the separator.

JavaScript

let animals = "giraffe,lion,wolf,hippo,cat,racoon"

Python

animals = "giraffe,lion,wolf,hippo,cat,racoon"

When the animals string is split using the comma, an array of animal names is created.

JavaScript

let animals = "giraffe,lion,wolf,hippo,cat,racoon"
let animalNames = animals.split(",")

Python

animals = "giraffe,lion,wolf,hippo,cat,racoon"
animalNames = animals.split(",")

If you wanted to get the "hippo" string, just select the string from animalNames at the index of 3.

JavaScript

let animals = "giraffe,lion,wolf,hippo,cat,racoon"
let animalNames = animals.split(",")
let hippo = animalNames[3]

Python

animals = "giraffe,lion,wolf,hippo,cat,racoon"
animalNames = animals.split(",")
hippo = animalNames[3]
執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにMakeCodeを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む