<?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>文字列を置換するにはString#subまたはString#gsubを使う。String#subはマッチした最初の1つだけを、String#gsubはマッチしたすべての文字列を置換した新しい文字列を返す。これらのメソッドの基本的な使い方は第1引数に置換対象の文字列か正規表現を指定し、第2引数に置換後の文字列を指定する方法だ。 p &quot;foo bar buz&quot;.sub('b', 'p') #=&gt; &quot;foo par buz&quot; p &quot;foo bar buz&quot;.gsub(/b/, 'p') #=&gt; &quot;foo par puz&quot; 第2引数を指定する代わりに、ブロックを指定することもできる。この場合はブロック…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Frubytips86.hatenablog.com%2Fentry%2F2014%2F04%2F02%2F182344&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-04-02 18:23:44</published>
  <title>文字列を置換する</title>
  <type>rich</type>
  <url>https://rubytips86.hatenablog.com/entry/2014/04/02/182344</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
