{"id":5170,"date":"2023-01-05T12:07:27","date_gmt":"2023-01-05T04:07:27","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5170"},"modified":"2023-01-05T12:07:27","modified_gmt":"2023-01-05T04:07:27","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e5%ad%97%e4%b8%b2%e7%9a%84%e6%b1%82%e5%ad%90%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%ba%e7%8f%be%e6%ac%a1%e6%95%b8countsubstrings","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e5%ad%97%e4%b8%b2%e7%9a%84%e6%b1%82%e5%ad%90%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%ba%e7%8f%be%e6%ac%a1%e6%95%b8countsubstrings\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528TypeScript\u5b57\u4e32\u7684\u6c42\u5b50\u5b57\u7b26\u4e32\u51fa\u73fe\u6b21\u6578(countSubstrings)"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u5b57\u4e32, \u6c42\u5b50\u5b57\u7b26\u4e32\u51fa\u73fe\u6b21\u6578, countSubstrings\"><\/p>\n<h1>\u4f7f\u7528 TypeScript \u5b57\u4e32\u7684\u6c42\u5b50\u5b57\u7b26\u4e32\u51fa\u73fe\u6b21\u6578(countSubstrings)<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u958b\u767c\u51fa\u66f4\u512a\u79c0\u7684\u7a0b\u5f0f\u78bc\u3002\u5176\u4e2d\u4e00\u500b\u529f\u80fd\u5c31\u662f\u6c42\u5b50\u5b57\u7b26\u4e32\u51fa\u73fe\u6b21\u6578\uff0c\u4e5f\u5c31\u662f countSubstrings\u3002<\/p>\n<p>countSubstrings \u662f\u4e00\u500b TypeScript \u5b57\u4e32\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u8a08\u7b97\u4e00\u500b\u5b57\u4e32\u4e2d\u67d0\u500b\u5b50\u5b57\u7b26\u4e32\u51fa\u73fe\u7684\u6b21\u6578\u3002\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u8655\u7406\u5b57\u4e32\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u5feb\u901f\u5730\u5b8c\u6210\u5b57\u4e32\u8655\u7406\u7684\u5de5\u4f5c\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4f7f\u7528 countSubstrings \u7684\u65b9\u6cd5\u5f88\u7c21\u55ae\uff0c\u53ea\u9700\u8981\u50b3\u5165\u5169\u500b\u53c3\u6578\uff0c\u7b2c\u4e00\u500b\u53c3\u6578\u662f\u8981\u641c\u5c0b\u7684\u5b57\u4e32\uff0c\u7b2c\u4e8c\u500b\u53c3\u6578\u662f\u8981\u641c\u5c0b\u7684\u5b50\u5b57\u7b26\u4e32\u3002\u5b83\u6703\u56de\u50b3\u4e00\u500b\u6578\u5b57\uff0c\u4ee3\u8868\u8a72\u5b50\u5b57\u7b26\u4e32\u5728\u5b57\u4e32\u4e2d\u51fa\u73fe\u7684\u6b21\u6578\u3002<\/p>\n<p>\u8209\u500b\u4f8b\u5b50\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u5b57\u4e32 <code>\"Hello World\"<\/code>\uff0c\u6211\u5011\u60f3\u8981\u77e5\u9053 <code>\"l\"<\/code> \u9019\u500b\u5b57\u6bcd\u5728\u9019\u500b\u5b57\u4e32\u4e2d\u51fa\u73fe\u7684\u6b21\u6578\uff0c\u6211\u5011\u53ef\u4ee5\u4f7f\u7528 countSubstrings \u4f86\u8a08\u7b97\uff1a<\/p>\n<pre><code class=\"line-numbers\">let str = \"Hello World\";\nlet count = countSubstrings(str, \"l\");\nconsole.log(count); \/\/ 3\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c<code>\"l\"<\/code> \u9019\u500b\u5b57\u6bcd\u5728 <code>\"Hello World\"<\/code> \u9019\u500b\u5b57\u4e32\u4e2d\u51fa\u73fe\u4e86 3 \u6b21\uff0ccountSubstrings \u5c31\u53ef\u4ee5\u5e6b\u6211\u5011\u8a08\u7b97\u51fa\u4f86\u3002<\/p>\n<p>countSubstrings \u9664\u4e86\u53ef\u4ee5\u7528\u4f86\u8a08\u7b97\u5b57\u4e32\u4e2d\u5b50\u5b57\u7b26\u4e32\u51fa\u73fe\u7684\u6b21\u6578\uff0c\u9084\u53ef\u4ee5\u7528\u4f86\u641c\u5c0b\u5b57\u4e32\u4e2d\u662f\u5426\u6709\u67d0\u500b\u5b50\u5b57\u7b26\u4e32\uff0c\u53ea\u8981\u628a\u7b2c\u4e8c\u500b\u53c3\u6578\u8a2d\u5b9a\u70ba\u8981\u641c\u5c0b\u7684\u5b50\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u56de\u50b3\u7684\u6578\u5b57\u5927\u65bc 0\uff0c\u5c31\u4ee3\u8868\u5b57\u4e32\u4e2d\u6709\u8a72\u5b50\u5b57\u7b26\u4e32\uff0c\u53cd\u4e4b\u5247\u6c92\u6709\u3002<\/p>\n<p>countSubstrings \u662f TypeScript \u4e2d\u4e00\u500b\u5f88\u6709\u7528\u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u8655\u7406\u5b57\u4e32\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u5feb\u901f\u5730\u5b8c\u6210\u5b57\u4e32\u8655\u7406\u7684\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1aTypeScript\u63d0\u4f9b\u4e86\u4e00\u500bcountSubstrings()\u51fd\u6578\uff0c\u53ef\u4ee5\u8a08\u7b97\u5b57\u4e32\u4e2d\u5b50\u5b57\u7b26\u4e32\u51fa\u73fe\u7684\u6b21\u6578\uff0c\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528countSubstrings()\u51fd\u6578\uff0c\u4ee5\u53ca\u5b83\u7684\u512a\u9ede\u548c\u7f3a\u9ede\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[187],"tags":[186],"class_list":["post-5170","post","type-post","status-publish","format-standard","hentry","category-typescript","tag-typescript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1lo","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=5170"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5170\/revisions"}],"predecessor-version":[{"id":5171,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5170\/revisions\/5171"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}