{"id":937,"date":"2020-05-16T23:33:11","date_gmt":"2020-05-16T14:33:11","guid":{"rendered":"https:\/\/auto-worker.com\/blog\/?p=937"},"modified":"2020-10-06T00:11:14","modified_gmt":"2020-10-05T15:11:14","slug":"post-937","status":"publish","type":"post","link":"https:\/\/auto-worker.com\/blog\/?p=937","title":{"rendered":"Google Apps Script\u306e\u6587\u5b57\u5217\u3092\u691c\u7d22\u3059\u308b\u65b9\u6cd5(indexOf,lastIndexOf,search\u30e1\u30bd\u30c3\u30c9)"},"content":{"rendered":"<p>Google Apps Script\u3067\u6587\u5b57\u5217\u306e\u4e2d\u8eab\u3092\u691c\u7d22\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>indexOf\u3001lastIndexOf\u3001search\u306e3\u3064\u306e\u6587\u5b57\u5217\u691c\u7d22\u306e\u65b9\u6cd5\u3068\u3001\u305d\u308c\u305e\u308c\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>GAS\u3067\u6587\u5b57\u5217\u306e\u691c\u7d22\u306f\u4e3b\u306b3\u7a2e\u985e\u306e\u65b9\u6cd5<\/h2>\n<p>Google Apps Script(GAS)\u3067\u6587\u5b57\u5217\u306e\u691c\u7d22\u3092\u884c\u3046\u5834\u5408\u306f\u3001\u4e3b\u306b\u4ee5\u4e0b\u306e3\u7a2e\u985e\u30e1\u30bd\u30c3\u30c9\u3067\u884c\u3044\u307e\u3059\u3002<\/p>\n<ol>\n<li>indexOf\u30e1\u30bd\u30c3\u30c9<\/li>\n<li>lastIndexOf\u30e1\u30bd\u30c3\u30c9<\/li>\n<li>search\u30e1\u30bd\u30c3\u30c9<\/li>\n<\/ol>\n<p>GAS\u3067\u6587\u5b57\u5217\u691c\u7d22\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u306f\u3001\u3088\u304findexOf\u30e1\u30bd\u30c3\u30c9\u304c\u7528\u3044\u3089\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u308c\u305e\u308c\u30e1\u30bd\u30c3\u30c9\u306e\u5f79\u5272\u304c\u5c11\u3057\u305a\u3064\u7570\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>GAS\u306eindexOf,lastIndexOf,search\u30e1\u30bd\u30c3\u30c9\u306e\u69cb\u6587<\/h2>\n<p>3\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u69cb\u6587\u306b\u52a0\u3048\u3001\u4f8b\u6587\u3068\u3057\u3066\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><code>String.indexOf(word [,from])<\/code><\/p>\n<p>\u203bfrom\u306e\u5f15\u6570\u306f\u7701\u7565\u53ef\u80fd\u3002\u7701\u7565\u3067\u6700\u521d\u306e\u6587\u5b57\u304b\u3089\u691c\u7d22\u3059\u308b<\/p>\n<p><strong>\u2192\u6587\u5b57\u5217\u304b\u3089\u691c\u7d22\u6587\u5b57\u5217word\u3092from\u6587\u5b57\u76ee\u304b\u3089\u6700\u5f8c\u306e\u6587\u5b57\u307e\u3067\u691c\u7d22\u3057\u3001\u4e00\u81f4\u3057\u305f\u4f4d\u7f6e\u3092\u8fd4\u3059<\/strong><\/p>\n<p><code>String.lastIndexOf(word [,from])<\/code><\/p>\n<p>\u203bfrom\u306e\u5f15\u6570\u306f\u7701\u7565\u53ef\u80fd\u3002\u7701\u7565\u3067\u6700\u5f8c\u306e\u6587\u5b57\u304b\u3089\u691c\u7d22\u3059\u308b<\/p>\n<p><strong>\u2192\u6587\u5b57\u5217\u304b\u3089\u691c\u7d22\u6587\u5b57\u5217word\u3092from\u6587\u5b57\u76ee\u304b\u3089\u6700\u521d\u306e\u6587\u5b57\u307e\u3067\u691c\u7d22\u3057\u3001\u4e00\u81f4\u3057\u305f\u4f4d\u7f6e\u3092\u8fd4\u3059<\/strong><\/p>\n<p><code>String.search(word)<\/code><\/p>\n<p>\u203bword\u5f15\u6570\u306f\u6587\u5b57\u5217\u3060\u3051\u3067\u306a\u304f\u3001\u6b63\u898f\u8868\u73fe\u3082\u6307\u5b9a\u53ef\u80fd<\/p>\n<p><strong>\u2192\u6587\u5b57\u5217\u304b\u3089\u691c\u7d22\u6587\u5b57\u5217word\u3092\u6700\u521d\u306e\u6587\u5b57\u304b\u3089\u6700\u5f8c\u306e\u6587\u5b57\u307e\u3067\u691c\u7d22\u3057\u3001\u4e00\u81f4\u3057\u305f\u4f4d\u7f6e\u3092\u8fd4\u3059<\/strong><\/p>\n<p>\u306a\u304a\u3001\u691c\u7d22\u6587\u5b57\u5217\u306b\u4e00\u81f4\u3059\u308b\u3082\u306e\u304c\u306a\u3044\u5834\u5408\u306f-1\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>GAS\u6587\u5b57\u5217\u3092\u691c\u7d22\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\n<p>Google Apps Script\u3067\u6587\u5b57\u5217\u3092\u691c\u7d22\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u305d\u308c\u305e\u308c\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-938\" src=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001.jpg\" alt=\"Google Apps Script(GAS)\u306e\u6587\u5b57\u5217\u3092\u691c\u7d22\u3059\u308bindexOf,lastIndexOf,search\u30e1\u30bd\u30c3\u30c9\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\" width=\"1200\" height=\"631\" srcset=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001.jpg 1200w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001-300x158.jpg 300w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001-768x404.jpg 768w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001-1024x538.jpg 1024w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001-530x279.jpg 530w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001-565x297.jpg 565w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001-710x373.jpg 710w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/05\/20200516_auto_001-725x381.jpg 725w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><code>function myFunction() {<br \/>\nlet testString = \"\u308a\u3093\u3054\u3001\u307f\u304b\u3093\u3001\u3076\u3069\u3046\u3001\u3044\u3061\u3054\u3001\u3082\u3082\";<br \/>\nLogger.log(testString.indexOf(\"\u307f\u304b\u3093\"));<br \/>\nLogger.log(testString.lastIndexOf(\"\u307f\u304b\u3093\"));<br \/>\nLogger.log(testString.search(\"\u307f\u304b\u3093\"));<br \/>\n}<\/code><\/p>\n<p>\u3044\u305a\u308c\u3082\u691c\u7d22\u3067\u30d2\u30c3\u30c8\u3057\u305f\u4f4d\u7f6e\u3092\u8fd4\u3059\u305f\u3081\u3001\u6587\u5b57\u5217\u3092\u524d\u304b\u3089\u6570\u3048\u305f4\u304c\u30ed\u30b0\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>indexOf\u3068lastIndexOf\u306e\u9055\u3044\u306f\u691c\u7d22\u306e\u65b9\u5411<\/h2>\n<p>indexOf\u3068lastIndexOf\u306e\u5927\u304d\u306a\u9055\u3044\u306f\u691c\u7d22\u3059\u308b\u65b9\u5411\u3067\u3059\u3002<\/p>\n<p>indexOf\u30e1\u30bd\u30c3\u30c9\u306e\u5834\u5408\u306f\u3001\u6587\u5b57\u5217\u306e\u524d\u304b\u3089\u5f8c\u308d\u306b\u5411\u304b\u3063\u3066\u691c\u7d22\u3059\u308b\u524d\u65b9\u691c\u7d22\u3067\u3059\u3002<\/p>\n<p>\u305d\u308c\u306b\u5bfe\u3057\u3001lastIndexOf\u30e1\u30bd\u30c3\u30c9\u306f\u6587\u5b57\u5217\u306e\u5f8c\u308d\u304b\u3089\u524d\u306b\u5411\u304b\u3063\u3066\u691c\u7d22\u3059\u308b\u5f8c\u65b9\u691c\u7d22\u3067\u3059\u3002<\/p>\n<p>\u691c\u7d22\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u306b\u521d\u3081\u3066\u30d2\u30c3\u30c8\u3057\u305f\u4f4d\u7f6e\u3092\u8fd4\u5374\u3059\u308b\u305f\u3081\u3001\u691c\u7d22\u306b\u30d2\u30c3\u30c8\u3059\u308b\u5834\u6240\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u3001indexOf\u3068lastIndexOf\u306e\u7d50\u679c\u306b\u9055\u3044\u304c\u751f\u3058\u307e\u3059\u3002<\/p>\n<p><code>function myFunction() {<br \/>\nlet testString = \"\u308a\u3093\u3054\u3001\u307f\u304b\u3093\u3001\u3076\u3069\u3046\u3001\u3044\u3061\u3054\u3001\u3082\u3082\";<br \/>\nLogger.log(testString.indexOf(\"\u3054\"));<br \/>\nLogger.log(testString.lastIndexOf(\"\u3054\"));<br \/>\n}<\/code><\/p>\n<p>\u3053\u306e\u5834\u5408\u3001indexOf\u306f\u308a\u3093\u3054\u306e\u300c\u3054\u300d\u3092\u30d2\u30c3\u30c8\u3057\u307e\u3059\u304c\u3001lastIndexOf\u306f\u3044\u3061\u3054\u306e\u300c\u3054\u300d\u306b\u30d2\u30c3\u30c8\u3057\u30012\u306814\u3068\u8fd4\u5374\u3059\u308b\u7d50\u679c\u304c\u7570\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>search\u306f\u6b63\u898f\u8868\u73fe\u306e\u691c\u7d22\u3082\u53ef\u80fd<\/h2>\n<p>GAS\u306e\u6587\u5b57\u5217\u306e\u3082\u3046\u3072\u3068\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u3001search\u3067\u306f\u6587\u5b57\u5217\u3060\u3051\u3067\u306a\u304f\u6b63\u898f\u8868\u73fe\u306b\u3088\u308b\u691c\u7d22\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u4ee3\u308f\u308a\u3001\u6307\u5b9a\u3067\u304d\u308b\u5f15\u6570\u306f\u691c\u7d22\u30ef\u30fc\u30c9\u3060\u3051\u306a\u306e\u3067\u3001\u691c\u7d22\u3092\u30b9\u30bf\u30fc\u30c8\u3055\u305b\u308b\u4f4d\u7f6e\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<h2>indexOf\u3068lastIndexOf\u3068search\u30e1\u30bd\u30c3\u30c9\u306e\u4f7f\u3044\u5206\u3051<\/h2>\n<p>Google Apps Script\u3067\u6587\u5b57\u5217\u306e\u691c\u7d22\u3092\u884c\u3046\u5834\u5408\u3001indexOf\u304c\u3088\u304f\u7528\u3044\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u30cd\u30c3\u30c8\u4e0a\u3067\u3082\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u304c\u8c4a\u5bcc\u306a\u306e\u3067\u3001indexOf\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u306e\u304c\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u691c\u7d22\u306b\u4e00\u81f4\u3059\u308b\u30ef\u30fc\u30c9\u304c\u8907\u6570\u3042\u308a\u3001\u5f8c\u65b9\u691c\u7d22\u306e\u3088\u3044\u5834\u5408\u306flastIndexOf\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u901a\u5e38\u306e\u6587\u5b57\u5217\u8868\u73fe\u3060\u3051\u3067\u306a\u304f\u3001\u6b63\u898f\u8868\u73fe\u306b\u3088\u308b\u691c\u7d22\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306fsearch\u30e1\u30bd\u30c3\u30c9\u3068\u3044\u3063\u305f\u4f7f\u3044\u5206\u3051\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081\u30fb\u7d42\u308f\u308a\u306b<\/h2>\n<p>\u4eca\u56de\u3001Google Apps Script(GAS)\u306e\u6587\u5b57\u5217\u3067\u3001\u7279\u5b9a\u306e\u6587\u5b57\u3092\u691c\u7d22\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>GAS\u3067\u6587\u5b57\u5217\u691c\u7d22\u3092\u884c\u3046\u5834\u5408\u306b\u306f\u3001indexOf\u3001lastIndexOf\u3001search\u30e1\u30bd\u30c3\u30c9\u306e3\u7a2e\u985e\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u524d\u65b9\u691c\u7d22\u3084\u5f8c\u65b9\u691c\u7d22\u3068\u3044\u3063\u305f\u691c\u7d22\u306e\u4ed5\u7d44\u307f\u3084\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u304b\u3069\u3046\u304b\u3067\u4f7f\u3044\u5206\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u6587\u5b57\u5217\u691c\u7d22\u306e\u8981\u4ef6\u306b\u5fdc\u3058\u3001indexOf\u3001lastIndexOf\u3001search\u306e3\u3064\u3092\u4f7f\u3044\u5206\u3051\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u203bGoogle App Script\u3067\u306e\u6587\u5b57\u5217\u306e\u5404\u7a2e\u51e6\u7406\u30fb\u64cd\u4f5c\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u307e\u3068\u3081\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"0HeQJmF5U9\"><p><a href=\"https:\/\/auto-worker.com\/blog\/?p=1504\">GoogleApps Script(GAS)\u6587\u5b57\u5217\u306e\u51e6\u7406\u30fb\u64cd\u4f5c\u65b9\u6cd5\u307e\u3068\u3081(\u7f6e\u63db\/\u5909\u63db\/\u62bd\u51fa\/\u5206\u5272\/\u9023\u7d50)<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;GoogleApps Script(GAS)\u6587\u5b57\u5217\u306e\u51e6\u7406\u30fb\u64cd\u4f5c\u65b9\u6cd5\u307e\u3068\u3081(\u7f6e\u63db\/\u5909\u63db\/\u62bd\u51fa\/\u5206\u5272\/\u9023\u7d50)&#8221; &#8212; AutoWorker\u301cGoogle Apps Script(GAS)\u3068Sikuli\u3067\u59cb\u3081\u308b\u696d\u52d9\u6539\u5584\u5165\u9580\" src=\"https:\/\/auto-worker.com\/blog\/?p=1504&#038;embed=true#?secret=drxA0tA1JX#?secret=0HeQJmF5U9\" data-secret=\"0HeQJmF5U9\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Apps Script\u3067\u6587\u5b57\u5217\u306e\u4e2d\u8eab\u3092\u691c\u7d22\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 indexOf\u3001lastIndexOf\u3001search\u306e3\u3064\u306e\u6587\u5b57\u5217\u691c\u7d22\u306e\u65b9\u6cd5\u3068\u3001\u305d\u308c\u305e\u308c\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002 &nbsp;  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":938,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[14,289,290,291,179,288,292],"class_list":["post-937","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gas","tag-gas","tag-indexof","tag-lastindexof","tag-search","tag-179","tag-288","tag-292"],"_links":{"self":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/937","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=937"}],"version-history":[{"count":2,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/937\/revisions"}],"predecessor-version":[{"id":1736,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/937\/revisions\/1736"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/938"}],"wp:attachment":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}