<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>rdera</author_name>
  <author_url>https://blog.hatena.ne.jp/rdera/</author_url>
  <blog_title>rderaログ</blog_title>
  <blog_url>https://rdera.hatenadiary.org/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>やりたかったこと 以下のようなファイルを abc.txt &lt;aaa&gt;&lt;/aaa&gt; &lt;bbb&gt;&lt;/bbb&gt; &lt;ccc&gt;&lt;/ccc&gt; &lt;ddd&gt;&lt;/ddd&gt;以下のようなファイルへ書き換える abc.txt &lt;aaa&gt;&lt;/aaa&gt; &lt;bbb&gt;&lt;/bbb&gt; &lt;ccc&gt;hogehogehoge&lt;/ccc&gt; &lt;ddd&gt;&lt;/ddd&gt; コード #!/usr/bin/ruby open(&quot;abc.txt&quot;,&quot;r+&quot;) {|f| f.flock(File::LOCK_EX) body = f.read body = body.gsub(/(^&lt;bbb&gt;).*(&lt;\/bbb&gt;$)/) do |tmp| &quot;#{$1}…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Frdera.hatenadiary.org%2Fentry%2F20110311%2F1299807083&quot; title=&quot;rubyでファイル中の文字列を書き換える方法 - rderaログ&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>2011-03-11 10:31:23</published>
  <title>rubyでファイル中の文字列を書き換える方法</title>
  <type>rich</type>
  <url>https://rdera.hatenadiary.org/entry/20110311/1299807083</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
