{"id":79,"date":"2025-10-20T14:51:08","date_gmt":"2025-10-20T06:51:08","guid":{"rendered":"http:\/\/180.76.113.73:8080\/?p=79"},"modified":"2025-10-23T14:33:38","modified_gmt":"2025-10-23T06:33:38","slug":"c%e4%b8%ad%e5%87%a0%e7%a7%8d%e8%8e%b7%e5%8f%96%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%9a%84%e6%8c%87%e5%ae%9a%e6%96%87%e6%9c%ac%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.windafterglow.cn\/index.php\/2025\/10\/20\/c%e4%b8%ad%e5%87%a0%e7%a7%8d%e8%8e%b7%e5%8f%96%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%9a%84%e6%8c%87%e5%ae%9a%e6%96%87%e6%9c%ac%e7%9a%84%e6%96%b9%e6%b3%95\/","title":{"rendered":"C#\u4e2d\u51e0\u79cd\u83b7\u53d6\u5b57\u7b26\u4e32\u7684\u6307\u5b9a\u6587\u672c\u7684\u65b9\u6cd5"},"content":{"rendered":"<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u5206\u4eab3\u4e2aC#\u4e2d\u83b7\u53d6\u5b57\u7b26\u4e32\u6307\u5b9a\u6587\u672c\u7684\u65b9\u6cd5\u3002<\/p>\n<h4 class=\"wp-block-heading\">\u7b2c\u4e00\u79cd\uff1a\u4f20\u7edf\u5faa\u73af\u904d\u5386\u65b9\u5f0f<\/h4>\n<p class=\"wp-block-paragraph\">\u5c31\u662f\u6700\u4f20\u7edf\u7684\u57fa\u4e8e\u5faa\u73af\u904d\u5386\u7684\u65b9\u5f0f\u8fdb\u884c\u6307\u5b9a\u6587\u672c\u7684\u83b7\u53d6\u3002<\/p>\n<p class=\"wp-block-paragraph\"><strong>\u7279\u70b9<\/strong> : \u8fd9\u4e2a\u590d\u6742\u5ea6\u4e3aO(n)\uff0c\u4f46\u662f\u6d88\u8017\u5185\u5b58\u8f83\u5927\u3002<\/p>\n<details class=\"wp-block-details\"><summary><strong><em><mark style=\"background-color:#cf2e2e\" class=\"has-inline-color has-black-color is-layout-flow wp-block-details-is-layout-flow\">\u4ee3\u7801<\/mark><\/em><\/strong><\/summary>\n<pre class=\"wp-block-code\"><code>public string GetStrContentByForeach(string _str, string _contentStart) {\n    string _result = string.Empty;\n    string _tempStr = string.Empty;\n    int _endIndex = 0;\n    foreach (var x in _str) {\n        _tempStr += x;\n        _endIndex++;\n        if (_tempStr.Contains(_contentStart)) {\n            _endIndex = _endIndex - _contentStart.Length;\n            break;\n        }\n\n    }\n\n    _result = _str.Replace(_str.Substring(0, _endIndex), &quot;&quot;);\n    _result = _result.Replace(&quot;\\n&quot;, &quot;&quot;);\n    return _result;\n}<\/code><\/pre>\n<\/details>\n<p class=\"has-text-align-left wp-block-paragraph\"><\/p>\n<h4 class=\"wp-block-heading\">\u7b2c\u4e8c\u79cd\uff1a\u4f7f\u7528IndexOf<\/h4>\n<p class=\"wp-block-paragraph\">\u5176\u5b9eC#\u4e2d\u7684String\u5185\u7f6e\u4e86IndexOf\u65b9\u6cd5\u6765\u83b7\u53d6\u6307\u5b9a\u5185\u5bb9\u7684\u6307\u6570\uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u6307\u6570\u6765\u83b7\u53d6\u6307\u5b9a\u5185\u5bb9\u3002<\/p>\n<p class=\"wp-block-paragraph\"><strong>\u7279\u70b9<\/strong>\uff1a\u590d\u6742\u5ea6\u662fO(n),\u4f46\u662f\u5bf9\u5185\u5b58\u7684\u6d88\u8017\u53d8\u5f97\u5f88\u5c0f\u3002<\/p>\n<details class=\"wp-block-details\"><summary><strong><em><mark style=\"background-color:#cf2e2e\" class=\"has-inline-color has-black-color is-layout-flow wp-block-details-is-layout-flow\">\u4ee3\u7801<\/mark><\/em><\/strong><\/summary>\n<pre class=\"wp-block-code\"><code>public string GetStrContentByIndexOf(string _str, string _contentStart) {\n    string _result = string.Empty;\n    int _startIndex = _str.IndexOf(&quot;https:\/\/&quot;);\n    if (_startIndex != 0){\n         _result = _str.Substring(_startIndex).Trim();\n    }\n\n    return _result;\n}<\/code><\/pre>\n<\/details>\n<h4 class=\"wp-block-heading\">\u7b2c\u4e09\u79cd\uff1a\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/h4>\n<p class=\"wp-block-paragraph\">C#\u4e2d\u5185\u7f6e\u4e86\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u7c7b<code>Regex<\/code>\u6765\u5904\u7406\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<\/p>\n<p class=\"wp-block-paragraph\"><strong>\u7279\u70b9<\/strong>\uff1a\u6709\u66f4\u597d\u7684\u5339\u914d\u6a21\u5f0f\uff0c\u4f46\u662f\u901f\u5ea6\u8f83\u6162\uff0c\u800c\u4e14\u597d\u50cf\u5b58\u5728\u786c\u7f16\u7801\u3002<\/p>\n<details class=\"wp-block-details\"><summary><strong><em><mark style=\"background-color:#cf2e2e\" class=\"has-inline-color has-black-color is-layout-flow wp-block-details-is-layout-flow\">\u4ee3\u7801<\/mark><\/em><\/strong><\/summary>\n<pre class=\"wp-block-code\"><code>public string GetStrContentByExpress(string _str)\n{\n    string _result = string.Empty;\n    var _regex = Regex.Match(_str, @&quot;{\u6307\u5b9a\u7684\u6587\u672c\u5f00\u59cb}[^\\s]+&quot;);\n\n    if (_regex.Success){\n        _result = _regex.Value;\n    }\n\n    return _result;\n}<\/code><\/pre>\n<\/details>\n<figure class=\"wp-block-post-featured-image wp-duotone-unset-1\"><figure id=\"attachment_mmd_77\" class=\"wp-block-image \"><img decoding=\"async\" width=\"640\" height=\"360\" data-src=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1760940535-20250619195632175033419257720-scaled.jpg\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@3.0\/basic\/puff-load.svg\" onerror=\"imgError(this)\" class=\"attachment-640x576 size-640x576 lazyload\" alt=\"\" loading=\"lazy\" \/><noscript><img decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1760940535-20250619195632175033419257720-scaled.jpg\" class=\"attachment-640x576 size-640x576\" alt=\"\" loading=\"lazy\" \/><\/noscript><\/figure><\/figure>","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u91cc\u5206\u4eab3\u4e2aC#\u4e2d\u83b7\u53d6\u5b57\u7b26\u4e32\u6307\u5b9a\u6587\u672c\u7684\u65b9\u6cd5\u3002 \u7b2c\u4e00\u79cd\uff1a\u4f20\u7edf\u5faa\u73af\u904d\u5386\u65b9\u5f0f \u5c31\u662f\u6700\u4f20\u7edf\u7684\u57fa\u4e8e\u5faa\u73af\u904d\u5386\u7684\u65b9\u5f0f\u8fdb\u884c\u6307\u5b9a\u6587\u672c\u7684\u83b7\u53d6\u3002 \u7279\u70b9  &#8230;<\/p>","protected":false},"author":1,"featured_media":77,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[1],"tags":[9],"class_list":["post-79","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1","tag-net"],"_links":{"self":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":11,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions\/142"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/media\/77"}],"wp:attachment":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}