{"id":561,"date":"2009-08-02T22:45:00","date_gmt":"2009-08-02T02:45:00","guid":{"rendered":""},"modified":"2013-11-17T12:55:41","modified_gmt":"2013-11-17T04:55:41","slug":"%e5%88%a9%e7%94%a8%e6%ad%a3%e5%88%99%e5%88%a0%e9%99%a4%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%b8%ad%e7%9a%84html%e6%a0%87%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/561.html","title":{"rendered":"\u5229\u7528\u6b63\u5219\u5220\u9664\u5b57\u7b26\u4e32\u4e2d\u7684HTML\u6807\u8bb0"},"content":{"rendered":"<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n    public static string NoHTML(string Htmlstring) \/\/\u66ff\u6362HTML\u6807\u8bb0   \r\n    {\r\n\r\n        \/\/\u5220\u9664\u811a\u672c  \r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&lt;script&#x5B;^&gt;]*?&gt;.*?&lt;\/script&gt;&quot;, &quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        \/\/\u5220\u9664HTML  \r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&lt;(.&#x5B;^&gt;]*)&gt;&quot;, &quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;(&#x5B;\\r\\n])&#x5B;\\s]+&quot;, &quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;\u2013&gt;&quot;, &quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&lt;!\u2013.*&quot;, &quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(quot|#34);&quot;, &quot;\\&quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(amp|#38);&quot;, &quot;&amp;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(lt|#60);&quot;, &quot;&lt;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(gt|#62);&quot;, &quot;&gt;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(nbsp|#160);&quot;, &quot; &quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(iexcl|#161);&quot;, &quot;\\xa1&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(cent|#162);&quot;, &quot;\\xa2&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(pound|#163);&quot;, &quot;\\xa3&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;(copy|#169);&quot;, &quot;\\xa9&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&amp;#(\\d+);&quot;, &quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring = Regex.Replace(Htmlstring, @&quot;&lt;img&#x5B;^&gt;]*&gt;;&quot;, &quot;&quot;, RegexOptions.IgnoreCase);\r\n\r\n        Htmlstring.Replace(&quot;&lt;&quot;, &quot;&quot;);\r\n\r\n        Htmlstring.Replace(&quot;&gt;&quot;, &quot;&quot;);\r\n\r\n        Htmlstring.Replace(&quot;\\r\\n&quot;, &quot;&quot;);\r\n\r\n        Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();\r\n\r\n        return Htmlstring;\r\n\r\n    }\r\n\r\n<\/pre>\n<p>\u547d\u540d\u7a7a\u95f4\uff1ausing System.Text.RegularExpressions;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>public static string NoHTML(string Htmlstring) \/\/\u66ff\u6362HTML [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-561","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=561"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":4609,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/561\/revisions\/4609"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}