{"id":907,"date":"2018-08-18T21:27:13","date_gmt":"2018-08-18T12:27:13","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=907"},"modified":"2021-12-11T09:01:17","modified_gmt":"2021-12-11T00:01:17","slug":"sqlite3%e3%81%a7%e3%81%af%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%beregexp%e3%81%8c%e4%bd%bf%e7%94%a8%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%ef%bc%9f%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=907","title":{"rendered":"SQlite3\u3067\u306f\u6b63\u898f\u8868\u73fe(REGEXP)\u304c\u4f7f\u7528\u3067\u304d\u306a\u3044\uff1f\uff1f"},"content":{"rendered":"<p>Rails5\u306eactiveRecord\u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u305fSQL\u3092\u5b9f\u884c\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>sqlite&gt; SELECT \"notes\".* FROM \"notes\" WHERE content REGEXP 'hoge' ;\nError: no such function: REGEXP\n<\/code><\/pre>\n<p>activeRecord\u3067\u3082\u540c\u69d8\u3067\u3059\u3002<\/p>\n<pre><code>[13] pry(main)&gt; Note.all\n...\n#&lt;Note:0x000055701e73c740 id: 9, title: \"dev\", content: \"hogefuga\", user_id: 3, created_at: Sat, 28 Jul 2018 23:27:58 UTC +00:00, updated_at: Sat, 28 Jul 2018 23:27:58 UTC +00:00&gt;,\n#&lt;Note:0x000055701e73c560 id: 10, title: \"dev_\", content: \"hogehoge\", user_id: 3, created_at: Sat, 28 Jul 2018 23:28:21 UTC +00:00, updated_at: Sat, 28 Jul 2018 23:28:21 UTC +00:00&gt;]\n\n# \u4e00\u898b\u51fa\u6765\u3066\u3044\u308b\u3088\u3046\u306b\u898b\u3048\u308b\n[14] pry(main)&gt; Note.where(\"content REGEXP ?\", 'hoge')\n  Note Load (0.3ms)  SELECT \"notes\".* FROM \"notes\" WHERE (content REGEXP 'hoge')\n  Note Load (0.3ms)  SELECT  \"notes\".* FROM \"notes\" WHERE (content REGEXP 'hoge') LIMIT ?  [[\"LIMIT\", 11]]\n=&gt; #&lt;Note::ActiveRecord_Relation:0x3ff536212788&gt;\n\n# \u3057\u304b\u3057\u53d6\u5f97\u3067\u304d\u3066\u3044\u306a\u3044\n[15] pry(main)&gt; Note.where(\"content REGEXP ?\", 'hoge')[0]\n  Note Load (0.3ms)  SELECT \"notes\".* FROM \"notes\" WHERE (content REGEXP 'hoge')\nActiveRecord::StatementInvalid: SQLite3::SQLException: no such function: REGEXP: SELECT \"notes\".* FROM \"notes\" WHERE (content REGEXP 'hoge')\nfrom \/home\/yuis\/.rbenv\/versions\/2.4.2\/lib\/ruby\/gems\/2.4.0\/gems\/sqlite3-1.3.13\/lib\/sqlite3\/database.rb:91:in `initialize'\n<\/code><\/pre>\n<p>\u3067\u3001\u8abf\u3079\u308b\u3068\u3001\u3069\u3046\u3082\u60c5\u5831\u304c\u932f\u7d9c\u3057\u3066\u3066\u2026\u3002<\/p>\n<p>\u307e\u3068\u3081\u308b\u3068\u3001<\/p>\n<ul>\n<li>Sqlite3\u81ea\u4f53\u306f\u6b63\u898f\u8868\u73fe\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u308b =&gt; <a href=\"https:\/\/stackoverflow.com\/questions\/5071601\/how-do-i-use-regex-in-a-sqlite-query\">How do I use regex in a SQLite query? &#8211; Stack Overflow<\/a><\/li>\n<li>sentOS\u306eSqlite\u306f\u6b63\u898f\u8868\u73fe\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044 =&gt; <a href=\"https:\/\/shobon.hatenablog.com\/entry\/2018\/02\/14\/204350\">SQLite \u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046 &#8211; \u3057\u3087\u307c\u3093\u30e1\u30e2\u30ea \uff08\u00b4\u30fb\u03c9\u30fb\uff40\uff09<\/a><\/li>\n<li>\u6700\u65b0\u306eRails\u306eActiveRecord\u306fLIKE\u691c\u7d22\u3084\u6b63\u898f\u8868\u73fe\u691c\u7d22\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044 =&gt; <a href=\"https:\/\/teratail.com\/questions\/127161\">Ruby &#8211; Rails\u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3044\u3001\u4e00\u81f4\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u308a\u51fa\u3059\u65b9\u6cd5\u3092\u6559\u3048\u3066\u3044\u305f\u3060\u3051\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff1f(127161)\uff5cteratail<\/a><\/li>\n<li>activeRecord\u306f\u7121\u7406\u3060\u304c\u3001Arel\u306a\u3089\u6b63\u898f\u8868\u73fe\u691c\u7d22\u304c\u53ef\u80fd =&gt; <a href=\"http:\/\/mmmpa.hatenablog.com\/entry\/2016\/07\/20\/%60Regexp%60%E3%81%AA%E3%81%A9ActiveRecord%E3%81%A7%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E3%81%8C%E7%94%A8%E6%84%8F%E3%81%95%E3%82%8C%E3%81%A6%E3%81%84\"><code>Regexp<\/code>\u306a\u3069ActiveRecord\u3067\u30e1\u30bd\u30c3\u30c9\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u306a\u3044\u6a19\u6e96SQL\u306e\u6f14\u7b97\u5b50\u3092\u6e05\u304f\u6b63\u3057\u304f\u4f7f\u3046\u3002 &#8211; \u30f3\u30f3\u30f3\u30d1<\/a><\/li>\n<\/ul>\n<p>\u898b\u4e8b\u306b\u5206\u304b\u308a\u307e\u305b\u3093\u306d\u3002<\/p>\n<p>\u4f55\u304c\u3069\u3046\u306a\u3063\u3066\u308b\u3093\u3060\u304b\u2026\u3002<\/p>\n<p>\u89e3\u6c7a\u7b56\u3068\u3057\u3066\u306f\u3001\u3084\u306f\u308a\u3001\u3069\u3046\u3057\u3066\u3082LIKE\u691c\u7d22\u3068\u304bREGEXP\u3092\u4f7f\u3044\u305f\u3044\u306a\u3089\u3001SQlite\u304b\u3089mysql\u306a\u3069\u306b\u79fb\u884c\u3059\u308b\u3063\u3066\u306e\u304c\u4e00\u756a\u304b\u306a\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rails5\u306eactiveRecord\u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u305fSQL\u3092\u5b9f\u884c\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002 sq [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"acf":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8Rxwo-eD","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/907"}],"collection":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=907"}],"version-history":[{"count":2,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/907\/revisions"}],"predecessor-version":[{"id":3583,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/907\/revisions\/3583"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}