<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>K_Koh</author_name>
  <author_url>https://blog.hatena.ne.jp/K_Koh/</author_url>
  <blog_title>Just do IT</blog_title>
  <blog_url>https://k-koh.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
    <anon>Ruby on Rails</anon>
  </categories>
  <description>Ruby の場合 素の Ruby の場合、該当するメソッドはないため自作する。 数値をいったん文字列にして、正規表現を使ってカンマを加える。 数値.to_s.gsub(/(\d)(?=\d{3}+$)/, '\\1,') 使用例 irb(main)&gt; 500000000.to_s.gsub(/(\d)(?=\d{3}+$)/, '\\1,') =&gt; &quot;500,000,000&quot; Rails の場合 Rails だと Active Support の拡張機能を使っていろんな数値の書式を扱える。 Active Support コア拡張機能 - Railsガイド #カンマを加える 12345678.t…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fk-koh.hatenablog.com%2Fentry%2F2020%2F10%2F19%2F143751&quot; title=&quot;Ruby や Rails で桁数を3行ごとにカンマで区切る - Just do IT&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>2020-10-19 14:37:51</published>
  <title>Ruby や Rails で桁数を3行ごとにカンマで区切る</title>
  <type>rich</type>
  <url>https://k-koh.hatenablog.com/entry/2020/10/19/143751</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
