{"id":80066,"date":"2024-03-29T07:15:26","date_gmt":"2024-03-28T22:15:26","guid":{"rendered":"https://freelance.indieverse.co.jp/media/?p=80066"},"modified":"2026-06-08T16:08:40","modified_gmt":"2026-06-08T07:08:40","slug":"ruby-split","status":"publish","type":"post","link":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split","title":{"rendered":"【Ruby】splitで文字列を分割する方法を解説"},"content":{"rendered":"<ul>\n<li>splitメソッドの基本的な使い方</li>\n<li>様々なパターンでの分割方法</li>\n<li>splitメソッドの応用例</li>\n</ul>\n<p>について解説していきたいと思います。</p>\n<div class='balloon5'>\n<div class='faceicon'>\n\t\t\t<img src='https://pbs.twimg.com/profile_images/1230103371664613376/PHLMWlPU_400x400.jpg'></p>\n<div style='text-align:center'>DAI</div>\n</p></div>\n<div class='chatting'>\n<div class='says'><strong>splitは文字列を配列にするメソッド</strong>です。個人的には文字列からCSVファイルを作成する場合や、改行区切りのテキストを配列に変更したりするケースでよく使います。利用頻度もかなり高いので、ぜひ覚えてみてください。</div>\n</p></div>\n</p></div>\n<h2>splitメソッドの基礎知識</h2>\n<p>Rubyにおいて、文字列を手軽に配列に変換する方法の一つが<code>split</code>メソッドです。</p>\n<p>このメソッドは、指定されたパターンや文字で文字列を分割し、その結果を配列として返します。</p>\n<p>最も単純な形の<code>split</code>メソッドの使用例は以下の通りです：</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>sentence = \"This is a sample string\"\r\nwords = sentence.split\r\np words</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>実行結果:</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>[\"This\", \"is\", \"a\", \"sample\", \"string\"]</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>この例では、<code>split</code>メソッドは引数を与えずに使用されています。</p>\n<p><strong>デフォルトでは、空白文字（スペース、タブ、改行など）で文字列を分割します。</strong></p>\n<p>結果として、単語ごとに分割された配列が得られます。</p>\n<p>Rubyでは、<code>split</code>メソッドを使って、さまざまな方法で文字列を配列に変換できます。ここではその方法についていくつか紹介します。</p>\n<h2>デフォルトで分割する</h2>\n<p><code>split</code>メソッドを引数なしで使用すると、<strong>デフォルトで空白文字（スペース、タブ、改行）を分割基準とします。</strong>これにより、文中の各単語を素早く配列に格納することが可能です。</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>text = \"Ruby programming is fun\"\r\narray = text.split\r\np array</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>実行結果:</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>[\"Ruby\", \"programming\", \"is\", \"fun\"]</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>この方法は、文章から単語を簡単に分けたい時に役立ちます。</p>\n<h3>特定の区切り文字で分割する</h3>\n<p>区切り文字を指定して文字列を分割することもできます。</p>\n<p>例えば、カンマ <code>,</code> が区切り文字の場合は、以下のようにsplit関数の引数に追加します。</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>data = \"apple,banana,cherry\"\r\nfruits = data.split(\",\")\r\np fruits</code></pre>\n</div>\n<p>実行結果:</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>[\"apple\", \"banana\", \"cherry\"]</code></pre>\n</div>\n<p>この方法はCSV形式のデータを扱う場合などに便利です。</p>\n<h3>正規表現を用いた分割</h3>\n<p>区切り文字が一定しない、複雑なパターンの場合は正規表現を使って分割することができます。</p>\n<p>例えば、スペースまたはカンマで分割したい場合は以下のようにします。</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>sentence = \"Ruby,split method is very useful\"\r\nwords = sentence.split(/,\\s|\\s/)\r\np words</code></pre>\n</div>\n<p>実行結果:</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>[\"Ruby\", \"split\", \"method\", \"is\", \"very\", \"useful\"]</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>この例では、カンマの後にスペースがあるか、スペースのいずれかで分割しています。正規表現を用いることで、より柔軟な分割が可能になります。</p>\n<p>正規表現については、こちらのURLをご確認ください。</p>\n<p><a href=\"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-regular-expression\" target=\"_blank\" class=\"related-article-container\"><br />\n\t\t\t\t\t<span class=\"related-article__label\">合わせて読みたい</span></p>\n<div class=\"related-article__image\" style=\"background-image:url(https://freelance.indieverse.co.jp/media/wp-content/uploads/2022/11/code-g7e399f5d0_1280-150x150.jpg)\"></div>\n<div class=\"related-article__content\">\n<div class=\"related-article__title\">【Ruby】正規表現完全マニュアル | 置換, 抽出, メタ文字の利用などを解説</div>\n<div class=\"related-article__description\">Rubyの正規表現を基礎から実践まで網羅。検索・抽出・置換・分割、メタ文字や量指&#8230;</div>\n</p></div>\n<p>\t\t\t\t</a></p>\n<h3>文字単位での分割技法</h3>\n<p>場合によっては、文字列を一文字ずつ分割したいこともあります。</p>\n<p>そのような場合は、<strong>空文字列</strong>を引数として渡します。</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>word = \"Ruby\"\r\nchars = word.split(\"\")\r\np chars</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>実行結果:</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>[\"R\", \"u\", \"b\", \"y\"]</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>文字列を文字の配列に変換するときに使うと便利なテクニックです。</p>\n<h2>分割回数の限界設定</h2>\n<p>Rubyの<code>split</code>メソッドでは、分割回数も制御できます。</p>\n<p>これは、分割を行なう最大回数を制限するために使われます。指定された回数まで分割が行われたら、残りの部分は一つの要素として配列に追加されます。</p>\n<p>分割回数を指定するには、<code>split</code>メソッドの第二引数に数字を渡します。これにより、分割の限界を設定することが可能です。例えば、スペースで区切られた文字列を最初の2つの空白のみで分割したい場合は以下のようにします。</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>text = \"This is a split method example\"\r\nlimit_array = text.split(\" \", 3)\r\np limit_array</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>実行結果:</p>\n<p><code></code></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>[\"This\", \"is\", \"a split method example\"]</code></pre>\n</div>\n<p>&nbsp;</p>\n<p>この例で、<code>split</code>メソッドに<code>3</code>を渡しています。これは、最大で2回分割を行い（したがって3つの要素に）、それ以降のテキストを全て3つ目の要素として残すことを意味します。</p>\n<p>この機能は、大量のデータを扱う際に、最初の数個のデータポイントのみ必要とする場合などに便利です。また、特定のフォーマットのデータから先頭部分のみを素早く抽出したい場合にも活用できます。</p>\n<h2>splitメソッドの実用例</h2>\n<p><code>split</code>メソッドの応用例としては、ログファイルやCSVデータのパースがあります。ログファイルから特定の部分文字列を抽出したい場合や、CSV形式のデータから特定の列を取り出したい場合に、<code>split</code>メソッドは非常に有効です。</p>\n<p>例えば、単純なCSV形式のデータから各行の最初の列だけを取り出したい場合、以下のようなコードが考えられます。</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>csv_data = \"name,age,location\\nJohn,30,New York\\nSara,25,Los Angeles\"\r\nlines = csv_data.split(\"\\n\")\r\nnames = lines.map { |line| line.split(\",\", 2).first }\r\np names</code></pre>\n</div>\n<p>実行結果:</p>\n<p><code></code><code>[\"name\", \"John\", \"Sara\"]</code></p>\n<p>&nbsp;</p>\n<h2>RubyのsplitをRails案件で活かすには</h2>\n<p><code>split</code>は、Ruby on Railsの実務でも文字列の分割や入力値の整形で使われます。検索条件を分解する、ログやCSV風の文字列を処理する、URLやパラメータから必要な値を取り出すなど、Webアプリ開発では文字列処理の基礎が役立つ場面が多くあります。</p>\n<p>文字列処理を含むRails開発の実務イメージを持ちたい方は、<a href=\"https://freelance.indieverse.co.jp/job_listings/skills/389\">Ruby on Rails案件一覧</a>で、どのような開発案件が募集されているか見ておくと学習の優先順位を決めやすくなります。</p>\n<h2>参考文献</h2>\n<ul>\n<li><a href=\"https://docs.ruby-lang.org/ja/latest/method/String/i/split.html\">Ruby 3.3 リファレンスマニュアル  ライブラリ一覧  組み込みライブラリ  Stringクラス  split</a></li>\n</ul>\n","protected":false},"excerpt":{"rendered":"<p>Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。</p>\n","protected":false},"author":1,"featured_media":80033,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[190],"tags":[286],"class_list":["post-80066","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby","tag-ruby"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。\" />\n\t<meta name=\"robots\" content=\"max-image-preview:large\" />\n\t<meta name=\"author\" content=\"DAI\"/>\n\t<link rel=\"canonical\" href=\"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split\" />\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" />\n\t\t<meta property=\"og:locale\" content=\"ja_JP\" />\n\t\t<meta property=\"og:site_name\" content=\"インディバースフリーランスメディア - Indieverse Freelanceの公式メディアです\" />\n\t\t<meta property=\"og:type\" content=\"article\" />\n\t\t<meta property=\"og:title\" content=\"【Ruby】splitで文字列を分割する方法を解説 - インディバースフリーランスメディア\" />\n\t\t<meta property=\"og:description\" content=\"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。\" />\n\t\t<meta property=\"og:url\" content=\"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split\" />\n\t\t<meta property=\"article:published_time\" content=\"2024-03-28T22:15:26+00:00\" />\n\t\t<meta property=\"article:modified_time\" content=\"2026-06-08T07:08:40+00:00\" />\n\t\t<meta name=\"twitter:card\" content=\"summary\" />\n\t\t<meta name=\"twitter:title\" content=\"【Ruby】splitで文字列を分割する方法を解説 - インディバースフリーランスメディア\" />\n\t\t<meta name=\"twitter:description\" content=\"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。\" />\n\t\t<script type=\"application/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\/\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#blogposting\",\"name\":\"\\u3010Ruby\\u3011split\\u3067\\u6587\\u5b57\\u5217\\u3092\\u5206\\u5272\\u3059\\u308b\\u65b9\\u6cd5\\u3092\\u89e3\\u8aac - \\u30a4\\u30f3\\u30c7\\u30a3\\u30d0\\u30fc\\u30b9\\u30d5\\u30ea\\u30fc\\u30e9\\u30f3\\u30b9\\u30e1\\u30c7\\u30a3\\u30a2\",\"headline\":\"\\u3010Ruby\\u3011split\\u3067\\u6587\\u5b57\\u5217\\u3092\\u5206\\u5272\\u3059\\u308b\\u65b9\\u6cd5\\u3092\\u89e3\\u8aac\",\"author\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\"},\"publisher\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\/\\/freelance.dividable.net\\/wp-content\\/uploads\\/2024\\/03\\/coding-1853305_640.jpg\",\"width\":640,\"height\":427},\"datePublished\":\"2024-03-29T07:15:26+09:00\",\"dateModified\":\"2026-06-08T16:08:40+09:00\",\"inLanguage\":\"ja\",\"mainEntityOfPage\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#webpage\"},\"isPartOf\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#webpage\"},\"articleSection\":\"Ruby, Ruby\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#listItem\",\"position\":1,\"name\":\"\\u30db\\u30fc\\u30e0\",\"item\":\"https:\\/\\/freelance.dividable.net\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming#listItem\",\"name\":\"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming#listItem\",\"position\":2,\"name\":\"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\",\"item\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby#listItem\",\"name\":\"Ruby\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#listItem\",\"name\":\"\\u30db\\u30fc\\u30e0\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby#listItem\",\"position\":3,\"name\":\"Ruby\",\"item\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#listItem\",\"name\":\"\\u3010Ruby\\u3011split\\u3067\\u6587\\u5b57\\u5217\\u3092\\u5206\\u5272\\u3059\\u308b\\u65b9\\u6cd5\\u3092\\u89e3\\u8aac\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming#listItem\",\"name\":\"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#listItem\",\"position\":4,\"name\":\"\\u3010Ruby\\u3011split\\u3067\\u6587\\u5b57\\u5217\\u3092\\u5206\\u5272\\u3059\\u308b\\u65b9\\u6cd5\\u3092\\u89e3\\u8aac\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby#listItem\",\"name\":\"Ruby\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#organization\",\"name\":\"Indieverse Freelance\",\"description\":\"Indieverse Freelance\\u306e\\u516c\\u5f0f\\u30e1\\u30c7\\u30a3\\u30a2\\u3067\\u3059\",\"url\":\"https:\\/\\/freelance.dividable.net\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\",\"url\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster\",\"name\":\"DAI\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#webpage\",\"url\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split\",\"name\":\"\\u3010Ruby\\u3011split\\u3067\\u6587\\u5b57\\u5217\\u3092\\u5206\\u5272\\u3059\\u308b\\u65b9\\u6cd5\\u3092\\u89e3\\u8aac - \\u30a4\\u30f3\\u30c7\\u30a3\\u30d0\\u30fc\\u30b9\\u30d5\\u30ea\\u30fc\\u30e9\\u30f3\\u30b9\\u30e1\\u30c7\\u30a3\\u30a2\",\"description\":\"Ruby\\u306esplit\\u30e1\\u30bd\\u30c3\\u30c9\\u3067\\u6587\\u5b57\\u5217\\u3092\\u5206\\u5272\\u3059\\u308b\\u57fa\\u672c\\u304b\\u3089\\u3001\\u533a\\u5207\\u308a\\u6587\\u5b57\\u30fb\\u6b63\\u898f\\u8868\\u73fe\\u30fb\\u5206\\u5272\\u56de\\u6570\\u306e\\u6307\\u5b9a\\u3001\\u6587\\u5b57\\u5358\\u4f4d\\u306e\\u5206\\u5272\\u3001CSV\\u3084\\u30ed\\u30b0\\u306e\\u5b9f\\u7528\\u4f8b\\u307e\\u3067\\u30b5\\u30f3\\u30d7\\u30eb\\u4ed8\\u304d\\u3067\\u89e3\\u8aac\\u3057\\u307e\\u3059\\u3002\\u521d\\u5fc3\\u8005\\u3067\\u3082\\u3059\\u3050\\u4f7f\\u3048\\u308b\\u5b9f\\u8df5\\u7684\\u306a\\u4f7f\\u3044\\u65b9\\u3092\\u7db2\\u7f85\\u3057\\u307e\\u3059\\u3002\",\"inLanguage\":\"ja\",\"isPartOf\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#breadcrumblist\"},\"author\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\"},\"creator\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\/\\/freelance.dividable.net\\/wp-content\\/uploads\\/2024\\/03\\/coding-1853305_640.jpg\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split\\/#mainImage\",\"width\":640,\"height\":427},\"primaryImageOfPage\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-split#mainImage\"},\"datePublished\":\"2024-03-29T07:15:26+09:00\",\"dateModified\":\"2026-06-08T16:08:40+09:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#website\",\"url\":\"https:\\/\\/freelance.dividable.net\\/\",\"name\":\"\\u30a4\\u30f3\\u30c7\\u30a3\\u30d0\\u30fc\\u30b9\\u30d5\\u30ea\\u30fc\\u30e9\\u30f3\\u30b9\\u30e1\\u30c7\\u30a3\\u30a2\",\"description\":\"Indieverse Freelance\\u306e\\u516c\\u5f0f\\u30e1\\u30c7\\u30a3\\u30a2\\u3067\\u3059\",\"inLanguage\":\"ja\",\"publisher\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/#organization\"}}]}\n\t\t</script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"【Ruby】splitで文字列を分割する方法を解説 - インディバースフリーランスメディア","description":"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。","canonical_url":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https://schema.org","@graph":[{"@type":"BlogPosting","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#blogposting","name":"【Ruby】splitで文字列を分割する方法を解説 - インディバースフリーランスメディア","headline":"【Ruby】splitで文字列を分割する方法を解説","author":{"@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author"},"publisher":{"@id":"https://freelance.indieverse.co.jp/media/#organization"},"image":{"@type":"ImageObject","url":"https://freelance.indieverse.co.jp/media/wp-content/uploads/2024/03/coding-1853305_640.jpg","width":640,"height":427},"datePublished":"2024-03-29T07:15:26+09:00","dateModified":"2026-06-08T16:08:40+09:00","inLanguage":"ja","mainEntityOfPage":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#webpage"},"isPartOf":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#webpage"},"articleSection":"Ruby, Ruby"},{"@type":"BreadcrumbList","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/#listItem","position":1,"name":"ホーム","item":"https://freelance.indieverse.co.jp/media/","nextItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming#listItem","name":"プログラミング"}},{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming#listItem","position":2,"name":"プログラミング","item":"https://freelance.indieverse.co.jp/media/category/programming","nextItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming/ruby#listItem","name":"Ruby"},"previousItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/#listItem","name":"ホーム"}},{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming/ruby#listItem","position":3,"name":"Ruby","item":"https://freelance.indieverse.co.jp/media/category/programming/ruby","nextItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#listItem","name":"【Ruby】splitで文字列を分割する方法を解説"},"previousItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming#listItem","name":"プログラミング"}},{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#listItem","position":4,"name":"【Ruby】splitで文字列を分割する方法を解説","previousItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming/ruby#listItem","name":"Ruby"}}]},{"@type":"Organization","@id":"https://freelance.indieverse.co.jp/media/#organization","name":"Indieverse Freelance","description":"Indieverse Freelanceの公式メディアです","url":"https://freelance.indieverse.co.jp/media/"},{"@type":"Person","@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author","url":"https://freelance.indieverse.co.jp/media/author/wpmaster","name":"DAI"},{"@type":"WebPage","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#webpage","url":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split","name":"【Ruby】splitで文字列を分割する方法を解説 - インディバースフリーランスメディア","description":"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。","inLanguage":"ja","isPartOf":{"@id":"https://freelance.indieverse.co.jp/media/#website"},"breadcrumb":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#breadcrumblist"},"author":{"@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author"},"creator":{"@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author"},"image":{"@type":"ImageObject","url":"https://freelance.indieverse.co.jp/media/wp-content/uploads/2024/03/coding-1853305_640.jpg","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split/#mainImage","width":640,"height":427},"primaryImageOfPage":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split#mainImage"},"datePublished":"2024-03-29T07:15:26+09:00","dateModified":"2026-06-08T16:08:40+09:00"},{"@type":"WebSite","@id":"https://freelance.indieverse.co.jp/media/#website","url":"https://freelance.indieverse.co.jp/media/","name":"インディバースフリーランスメディア","description":"Indieverse Freelanceの公式メディアです","inLanguage":"ja","publisher":{"@id":"https://freelance.indieverse.co.jp/media/#organization"}}]},"og:locale":"ja_JP","og:site_name":"インディバースフリーランスメディア - Indieverse Freelanceの公式メディアです","og:type":"article","og:title":"【Ruby】splitで文字列を分割する方法を解説 - インディバースフリーランスメディア","og:description":"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。","og:url":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split","article:published_time":"2024-03-28T22:15:26+00:00","article:modified_time":"2026-06-08T07:08:40+00:00","twitter:card":"summary","twitter:title":"【Ruby】splitで文字列を分割する方法を解説 - インディバースフリーランスメディア","twitter:description":"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者でもすぐ使える実践的な使い方を網羅します。"},"aioseo_meta_data":{"post_id":"80066","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"#aioseo-article-67f600e25e1b5","slug":"article","graphName":"Article","label":"記事","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"limit_modified_date":false,"created":"2024-03-28 22:01:45","updated":"2025-09-08 22:44:16","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https://freelance.indieverse.co.jp/media/\" title=\"ホーム\">ホーム</a>\n\t\t</span><span class=\"aioseo-breadcrumb-separator\">»</span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https://freelance.indieverse.co.jp/media/category/programming\" title=\"プログラミング\">プログラミング</a>\n\t\t</span><span class=\"aioseo-breadcrumb-separator\">»</span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https://freelance.indieverse.co.jp/media/category/programming/ruby\" title=\"Ruby\">Ruby</a>\n\t\t</span><span class=\"aioseo-breadcrumb-separator\">»</span><span class=\"aioseo-breadcrumb\">\n\t\t\t【Ruby】splitで文字列を分割する方法を解説\n\t\t</span></div>","aioseo_breadcrumb_json":[{"label":"ホーム","link":"https://freelance.indieverse.co.jp/media/"},{"label":"プログラミング","link":"https://freelance.indieverse.co.jp/media/category/programming"},{"label":"Ruby","link":"https://freelance.indieverse.co.jp/media/category/programming/ruby"},{"label":"【Ruby】splitで文字列を分割する方法を解説","link":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-split"}],"meta_description":"Rubyのsplitメソッドで文字列を分割する基本から、区切り文字・正規表現・分割回数の指定、文字単位の分割、CSVやログの実用例までサンプル付きで解説します。初心者で...","_links":{"self":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts/80066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts"}],"about":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/types/post"}],"author":[{"embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/users/1"}],"replies":[{"embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/comments?post=80066"}],"version-history":[{"count":6,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts/80066/revisions"}],"predecessor-version":[{"id":96850,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts/80066/revisions/96850"}],"wp:featuredmedia":[{"embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/media/80033"}],"wp:attachment":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/media?parent=80066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/categories?post=80066"},{"taxonomy":"post_tag","embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/tags?post=80066"}],"curies":[{"name":"wp","href":"https://api.w.org/{rel}","templated":true}]}}