<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>Thoames1212</author_name>
  <author_url>https://blog.hatena.ne.jp/Thoames1212/</author_url>
  <blog_title>とーますメモ</blog_title>
  <blog_url>https://thoames.hatenadiary.jp/</blog_url>
  <categories>
    <anon>TypeScript</anon>
    <anon>JavaScript</anon>
  </categories>
  <description>Validationメッセージなどのメッセージには決まった文言が入るが、一部を置き換えたい場合などは、テンプレートリテラルよりC言語系で使われるSprintfが便利なのだが、JavaScriptにないため自作した。 export const sprintf = (format: string, ...args: string[]): string =&gt; { return format.replace(/{(\d+)}/g, (_match, index) =&gt; { return args[index]; }); }; sprintf('{0}を入力してください', '名前') =&gt; '名前を入…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fthoames.hatenadiary.jp%2Fentry%2F2022%2F05%2F16%2F104612&quot; title=&quot;TypeScriptで簡易Sprintfを作成する - とーますメモ&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>2022-05-16 10:46:12</published>
  <title>TypeScriptで簡易Sprintfを作成する</title>
  <type>rich</type>
  <url>https://thoames.hatenadiary.jp/entry/2022/05/16/104612</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
