{"id":471,"date":"2007-09-07T19:09:19","date_gmt":"2007-09-07T11:09:19","guid":{"rendered":"http:\/\/fdream.net\/blog\/article\/471.aspx"},"modified":"2011-09-11T14:00:34","modified_gmt":"2011-09-11T14:00:34","slug":"c%ef%bc%9a%e5%9c%a8%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e6%9b%bf%e6%8d%a2%e6%97%b6%e8%bf%9b%e8%a1%8c%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/471","title":{"rendered":"C#\uff1a\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\u65f6\u8fdb\u884c\u5904\u7406"},"content":{"rendered":"<p>\u6709\u4e9b\u65f6\u5019\u6211\u5076\u4eec\u5e0c\u671b\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u66ff\u6362\u4e2d\u5bf9\u66ff\u6362\u7684\u5b57\u7b26\u6362\u8fdb\u884c\u7b80\u5355\u7684\u5904\u7406\uff0c\u6bd4\u5982\u628a\u6240\u6709\u7684A\u4f9d\u6b21\u66ff\u6362\u4e3aB1\u3001B2\u3001B3\u2026\u2026\u8fd9\u5c31\u9700\u5728\u66ff\u6362\u65f6\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u5904\u7406\uff0c\u5176\u5b9e\u8fd9\u4e2a\u5f88\u7b80\u5355\uff0c\u7528C#\u4e2d\u7684MatchEvaluator\u59d4\u6258\u5c31\u53ef\u4ee5\u4e86\u3002\u7b80\u5355\u7684\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre lang=\"cs\">\r\nprivate static int i = 0;\r\n\r\npublic static string ParseToHTML(string ubbString)\r\n{\r\nRegex rgx;\r\nstring htmlString = \"\";\r\n\r\nMatchEvaluator me = new MatchEvaluator(AddOne);\r\nrgx = new Regex(@\"\\[code\\](.*?)\\[\\\/code\\]\");\r\nhtmlString = rgx.Replace(htmlString, me);\r\n\r\nreturn htmlString;\r\n}\r\n\r\npublic static string AddOne(Match m)\r\n{\r\nstring code = m.Value.Substring(6, m.Value.Length - 13);\r\nstring codeString = @\"&lt;textarea class=\"code_text\" name=\"code&quot; + i + &quot;\"&gt;\" + code + \"&lt;\/textarea&gt;\";\r\ni++;\r\nreturn codeString;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e9b\u65f6\u5019\u6211\u5076\u4eec\u5e0c\u671b\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u66ff\u6362\u4e2d\u5bf9\u66ff\u6362\u7684\u5b57\u7b26\u6362\u8fdb\u884c\u7b80\u5355\u7684\u5904\u7406\uff0c\u6bd4\u5982\u628a\u6240\u6709\u7684A\u4f9d\u6b21\u66ff\u6362\u4e3aB1\u3001B2\u3001B3\u2026\u2026\u8fd9\u5c31\u9700\u5728\u66ff\u6362\u65f6\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u5904\u7406\uff0c\u5176\u5b9e\u8fd9\u4e2a\u5f88\u7b80\u5355\uff0c\u7528C#\u4e2d\u7684MatchEvaluator\u59d4\u6258\u5c31\u53ef\u4ee5\u4e86\u3002\u7b80\u5355\u7684\u793a\u4f8b\u5982\u4e0b\uff1a private static int i = 0; public static string ParseToHTML(string ubbString) { Regex rgx; string htmlString = &#8220;&#8221;; MatchEvaluator me = new MatchEvaluator(AddOne); rgx = new Regex(@&#8221;\\[code\\](.*?)\\[\\\/code\\]&#8221;); htmlString = rgx.Replace(htmlString, me); return htmlString; } public static string AddOne(Match m) { string code = m.Value.Substring(6, m.Value.Length &#8211; 13); string codeString = @&#8221;&lt;textarea class=&#8221;code_text&#8221; name=&#8221;code&quot; + &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[167,305],"class_list":["post-471","post","type-post","status-publish","format-standard","hentry","category-coding","tag-C","tag-305"],"views":15545,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=471"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/471\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}