{"id":5190,"date":"2023-01-05T12:10:02","date_gmt":"2023-01-05T04:10:02","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5190"},"modified":"2023-01-05T12:10:02","modified_gmt":"2023-01-05T04:10:02","slug":"%e4%ba%86%e8%a7%a3typescript%e5%ad%97%e4%b8%b2%e7%9a%84%e6%b1%82%e5%b0%be%e5%ad%90%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%bd%8d%e7%bd%aegetlastsubstringindex%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e4%ba%86%e8%a7%a3typescript%e5%ad%97%e4%b8%b2%e7%9a%84%e6%b1%82%e5%b0%be%e5%ad%90%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%bd%8d%e7%bd%aegetlastsubstringindex%e5%8a%9f%e8%83%bd\/","title":{"rendered":"\u4e86\u89e3TypeScript\u5b57\u4e32\u7684\u6c42\u5c3e\u5b50\u5b57\u7b26\u4e32\u4f4d\u7f6e(getLastSubstringIndex)\u529f\u80fd"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u5b57\u4e32, \u6c42\u5c3e\u5b50\u5b57\u7b26\u4e32\u4f4d\u7f6e, getLastSubstringIndex\"><\/p>\n<h1>TypeScript \u5b57\u4e32\u7684\u6c42\u5c3e\u5b50\u5b57\u7b26\u4e32\u4f4d\u7f6e(getLastSubstringIndex)<\/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\u5730\u958b\u767c\u51fa\u66f4\u9ad8\u54c1\u8cea\u7684\u7a0b\u5f0f\u78bc\u3002\u5176\u4e2d\u4e00\u500b\u529f\u80fd\u5c31\u662f\u6c42\u5c3e\u5b50\u5b57\u7b26\u4e32\u4f4d\u7f6e\uff0c\u4e5f\u5c31\u662f <strong>getLastSubstringIndex<\/strong>\u3002<\/p>\n<p>getLastSubstringIndex \u662f\u4e00\u500b TypeScript \u5167\u5efa\u7684\u51fd\u5f0f\uff0c\u5b83\u53ef\u4ee5\u7528\u4f86\u6c42\u51fa\u5b57\u4e32\u4e2d\u6307\u5b9a\u5b50\u5b57\u4e32\u7684\u6700\u5f8c\u4e00\u500b\u51fa\u73fe\u7684\u4f4d\u7f6e\u3002\u5b83\u7684\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: typescript\">\ngetLastSubstringIndex(str: string, substr: string): number\n<\/pre>\n<p>\u5176\u4e2d\uff0cstr \u662f\u8981\u641c\u5c0b\u7684\u5b57\u4e32\uff0csubstr \u662f\u8981\u641c\u5c0b\u7684\u5b50\u5b57\u4e32\u3002\u51fd\u5f0f\u6703\u56de\u50b3\u5b50\u5b57\u4e32\u6700\u5f8c\u4e00\u500b\u51fa\u73fe\u7684\u4f4d\u7f6e\uff0c\u5982\u679c\u6c92\u6709\u627e\u5230\u5247\u6703\u56de\u50b3 -1\u3002<\/p>\n<p>\u8209\u500b\u4f8b\u5b50\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u5b57\u4e32 <strong>&#8216;Hello World&#8217;<\/strong>\uff0c\u6211\u5011\u60f3\u8981\u627e\u51fa <strong>&#8216;o&#8217;<\/strong> \u9019\u500b\u5b57\u5143\u6700\u5f8c\u4e00\u6b21\u51fa\u73fe\u7684\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 getLastSubstringIndex \u51fd\u5f0f\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = 'Hello World';\nlet substr = 'o';\nlet index = getLastSubstringIndex(str, substr);\n\nconsole.log(index); \/\/ 8\n<\/pre>\n<p>\u5f9e\u7d50\u679c\u53ef\u4ee5\u770b\u51fa\uff0c<strong>&#8216;o&#8217;<\/strong> \u9019\u500b\u5b57\u5143\u6700\u5f8c\u4e00\u6b21\u51fa\u73fe\u7684\u4f4d\u7f6e\u662f 8\uff0c\u4e5f\u5c31\u662f\u5b57\u4e32\u4e2d\u7684\u7b2c\u4e5d\u500b\u5b57\u5143\u3002<\/p>\n<p>getLastSubstringIndex \u51fd\u5f0f\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6c42\u51fa\u5b57\u4e32\u4e2d\u6307\u5b9a\u5b50\u5b57\u4e32\u7684\u6700\u5f8c\u4e00\u500b\u51fa\u73fe\u7684\u4f4d\u7f6e\uff0c\u5c0d\u65bc\u958b\u767c\u8005\u4f86\u8aaa\u662f\u4e00\u500b\u975e\u5e38\u6709\u7528\u7684\u529f\u80fd\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>TypeScript \u63d0\u4f9b\u4e86\u4e00\u500b\u53eb\u505a <strong>getLastSubstringIndex<\/strong> \u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u6c42\u51fa\u5b57\u4e32\u4e2d\u6307\u5b9a\u5b50\u5b57\u4e32\u7684\u6700\u5f8c\u4e00\u500b\u51fa\u73fe\u7684\u4f4d\u7f6e\u3002\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6c42\u51fa\u5b57\u4e32\u4e2d\u6307\u5b9a\u5b50\u5b57\u4e32\u7684\u6700\u5f8c\u4e00\u500b\u51fa\u73fe\u7684\u4f4d\u7f6e\uff0c\u5c0d\u65bc\u958b\u767c\u8005\u4f86\u8aaa\u662f\u4e00\u500b\u975e\u5e38\u6709\u7528\u7684\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981(Description):TypeScript\u5b57\u4e32\u7684\u6c42\u5c3e\u5b50\u5b57\u7b26\u4e32\u4f4d\u7f6e(getLastSubstringIndex)\u662f\u4e00\u500b\u6709\u7528\u7684\u51fd\u6578\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5feb\u901f\u627e\u51fa\u5b57\u4e32\u4e2d\u6700\u5f8c\u4e00\u500b\u5b50\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e\uff0c\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528TypeScript\u5b57\u4e32\u7684\u6c42\u5c3e\u5b50\u5b57\u7b26\u4e32\u4f4d\u7f6e(getLastSubstringIndex)\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-5190","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-1lI","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5190","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=5190"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5190\/revisions"}],"predecessor-version":[{"id":5191,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5190\/revisions\/5191"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}