{"id":802,"date":"2022-12-19T17:55:16","date_gmt":"2022-12-19T09:55:16","guid":{"rendered":"http:\/\/wordpress.loc\/?p=802"},"modified":"2022-12-19T17:56:14","modified_gmt":"2022-12-19T09:56:14","slug":"software-4","status":"publish","type":"post","link":"https:\/\/www.nmking.io\/index.php\/2022\/12\/19\/802\/","title":{"rendered":"Arduino\u7684Split\u51fd\u6578"},"content":{"rendered":"\n<figure class=\"wp-block-pullquote\"><blockquote><p>Arduino\u96d6\u7136\u5c6c\u65bcC\u8a9e\u8a00\uff0c\u4f46\u662f\u5f88\u591a\u526f\u7a0b\u5f0f\u6c92\u6709\u5305\u9032\u53bb\uff0c\u6700\u8fd1\u8981\u6211\u62c6\u89e3CSV\u6a94\u6848\uff0c\u4e5f\u5c31\u662f\u9017\u865f\u5206\u9694\u6a94\uff0c\u767c\u73feArduino\u6c92\u6709\u539f\u751f\u7684split\u529f\u80fd\uff0c\u672c\u4f86\u60f3\u81ea\u5df1\u5beb\uff0c\u4f46\u662fGoogle\u4e00\u4e0b\u5c31\u6709\u4e86\uff0c\u5728\u6b64\u4ed8\u4e0a<\/p><\/blockquote><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u6b64\u526f\u7a0b\u5f0f\u7528\u4f86\u62c6\u89e3','\u5206\u9694\u7684\u5b57\u4e32\nString getValue(String data, char separator, int index){\n    int found = 0;\n    int strIndex&#91;] = { 0, -1 };\n    int maxIndex = data.length() - 1;\n    for (int i = 0; i &lt;= maxIndex &amp;&amp; found &lt;= index; i++) {\n        if (data.charAt(i) == separator || i == maxIndex) {\n            found++;\n            strIndex&#91;0] = strIndex&#91;1] + 1;\n            strIndex&#91;1] = (i == maxIndex) ? i+1 : i;\n        }\n    }\n    return found > index ? data.substring(strIndex&#91;0], strIndex&#91;1]) : \"\";\n}<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\u6642<\/p>\n\n\n\n<p>String a1=getValue(&#8220;aa,bb,cc&#8221;,&#8217;,&#8217;,0);<\/p>\n\n\n\n<p>\u5c31\u53ef\u4ee5\u6293\u5230aa\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Arduino\u96d6\u7136\u5c6c\u65bcC\u8a9e\u8a00\uff0c\u4f46\u662f\u5f88\u591a\u526f\u7a0b\u5f0f\u6c92\u6709\u5305\u9032\u53bb\uff0c\u6700\u8fd1\u8981\u6211\u62c6\u89e3CSV\u6a94\u6848\uff0c\u4e5f\u5c31\u662f\u9017\u865f\u5206\u9694\u6a94\uff0c\u767c\u73feArdu [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1,8],"tags":[],"class_list":["post-802","post","type-post","status-publish","format-standard","hentry","category-esp32","category-computer"],"blocksy_meta":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/comments?post=802"}],"version-history":[{"count":1,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/802\/revisions"}],"predecessor-version":[{"id":803,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/802\/revisions\/803"}],"wp:attachment":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/media?parent=802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/categories?post=802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/tags?post=802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}