<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>rubytips86</author_name>
  <author_url>https://blog.hatena.ne.jp/rubytips86/</author_url>
  <blog_title>Ruby Tips!</blog_title>
  <blog_url>https://rubytips86.hatenablog.com/</blog_url>
  <categories>
  </categories>
  <description>Ruby 1.8では、文字単位の指定で部分文字列を切り出すメソッドが存在しない。このため文字列を指定した文字数に切り詰めるには、String#sliceと正規表現を組み合わせなければならない。以下は文字列を5文字に切り詰める例だ。 p &quot;abc&quot;.slice(/\A.{,5}/m) #=&gt; &quot;abc&quot; p &quot;abcdefg&quot;.slice(/\A.{,5}/m) #=&gt; &quot;abcde&quot; p &quot;あいうえおかき&quot;.slice(/\A.{,5}/m) #=&gt; &quot;あいうえお&quot; Ruby 1.9では、文字単位の指定で部分文字列が切り出せるようになった。より簡単にString#sliceまたはString#…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Frubytips86.hatenablog.com%2Fentry%2F2014%2F03%2F19%2F092549&quot; title=&quot;文字列を指定した文字数に切り詰める - Ruby Tips!&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2014-03-19 09:25:49</published>
  <title>文字列を指定した文字数に切り詰める</title>
  <type>rich</type>
  <url>https://rubytips86.hatenablog.com/entry/2014/03/19/092549</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
