{"id":1778,"date":"2010-07-29T23:26:16","date_gmt":"2010-07-29T15:26:16","guid":{"rendered":"\/?p=1778"},"modified":"2020-01-16T23:54:20","modified_gmt":"2020-01-16T15:54:20","slug":"1778","status":"publish","type":"post","link":"https:\/\/www.justzz.com\/spec\/1778.html","title":{"rendered":"\u6b63\u5219\u8868\u8fbe\u5f0f\u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"<div>\n<p><span style=\"font-family: \u5b8b\u4f53;\"><strong>JavaScript \u7528\u6cd5<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #990099; font-family: \u5b8b\u4f53;\">&lt;script language=\"javascript\"&gt;<br \/>\nvar s=prompt(\"\u8f93\u5165\u9ad8\u4eae\u663e\u793a\u8bcd\uff1a\",\"\u594b\u53d1\");<br \/>\nvar reg=new RegExp(\"(\"+s+\")\",\"g\");<br \/>\nvar str=\"\u9eef\u7136\u594b\u53d1\uff0c\u594b\u53d1\u6280\u672f\u5728\u7ebf\";<br \/>\nvar newstr=str.replace(reg,\"&lt;font color=red&gt;$1&lt;\/font&gt;\");<br \/>\ndocument.write(newstr);<br \/>\n&lt;\/script&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: \u5b8b\u4f53;\"><strong>C# \u7528\u6cd5<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #990099; font-family: \u5b8b\u4f53;\">using System.Text.RegularExpressions;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #990099; font-family: \u5b8b\u4f53;\">htmlString = Regex.Replace(htmlString, @\"&lt;script[^&gt;]*?&gt;.*?&lt;\/script&gt;\", \"\", RegexOptions.IgnoreCase);<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #009900; font-family: \u5b8b\u4f53;\">\u6ce8\uff1a\u8be6\u7ec6\u8bf4\u660e\u8bf7\u53c2\u89c1MSDN<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: \u5b8b\u4f53;\"><strong>Java \u7528\u6cd5<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #990099; font-family: \u5b8b\u4f53;\">import java.util.regex.Matcher;<br \/>\nimport java.util.regex.Pattern;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #990099;\">String regEx=\"a+\";<br \/>\nPattern p=Pattern.compile(regEx);<br \/>\nMatcher m=p.matcher(\"aaabbced a ccdeaa\");<br \/>\nString s=m.replaceAll(\"A\");<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript \u7528\u6cd5 &nbsp; &lt;script language=\"javascript\"&gt; var s=prompt(\"\u8f93\u5165\u9ad8\u4eae\u663e\u793a\u8bcd\uff1a\",\"\u594b\u53d1\"); var reg=new RegExp(\"(\"+s+\")\",\"g\"); v&hellip;<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1778","post","type-post","status-publish","format-standard","hentry","category-t"],"_links":{"self":[{"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/posts\/1778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/comments?post=1778"}],"version-history":[{"count":0,"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/posts\/1778\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/media?parent=1778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/categories?post=1778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.justzz.com\/spec\/wp-json\/wp\/v2\/tags?post=1778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}