{"version":"1.0","published":"2026-07-27 00:00:00","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fml-rand-note.hatenablog.com%2Fentry%2Fruby%2Fstring-extraction\" title=\"\u3010Ruby\u3011\u6587\u5b57\u5217\u3000\u62bd\u51fa\u30e1\u30bd\u30c3\u30c9 - \u30e9\u30f3\u30c9ML\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","blog_title":"\u30e9\u30f3\u30c9ML","provider_name":"Hatena Blog","author_url":"https://blog.hatena.ne.jp/round-rand/","height":"190","url":"https://ml-rand-note.hatenablog.com/entry/ruby/string-extraction","categories":["Ruby"],"image_url":null,"blog_url":"https://ml-rand-note.hatenablog.com/","description":"slice \u6570\u5b57\u3092\u6307\u5b9a\u3059\u308b\u5834\u5408 str[a, b] str.slice(a, b) \u306f\u540c\u3058\u610f\u5473 str = \"hello\" # 2\u6587\u5b57\u76ee\u304b\u30893\u6587\u5b57\u53d6\u308a\u51fa\u3059 p str[2, 3] #=> \"llo\" p str.slice(2, 3) #=> \"llo\" \u6b63\u898f\u8868\u73fe\u6307\u5b9a\u306e\u5834\u5408 \u6b63\u898f\u8868\u73fe\u306b\u4e00\u81f4\u3059\u308b\u6700\u521d\u306e\u7b87\u6240\u3092\u6587\u5b57\u5217\u3068\u3057\u3066\u8fd4\u3059\u3002 str = \"12hello34\" # \u6570\u5b57\u304c\u9023\u7d9a\u3057\u3066\u3044\u308b\u7b87\u6240\u3092\u629c\u304d\u51fa\u3059 p str.slice(/\\d+/) #=> \"12\" # \u6570\u5b57 + \u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u306e\u7b87\u6240\u3092\u629c\u304d\u51fa\u3059 p str.slice(/\\d[a-z]/) #=> \"2h\" scan \u6b63\u898f\u8868\u73fe\u306b\u4e00\u81f4\u3057\u305f\u5168\u3066\u306e\u2026","author_name":"round-rand","width":"100%","title":"\u3010Ruby\u3011\u6587\u5b57\u5217\u3000\u62bd\u51fa\u30e1\u30bd\u30c3\u30c9","provider_url":"https://hatena.blog","type":"rich"}