用户在TextBox里输入:
<script>window</script>
kkk<script>window</script>
uuuuuuuu
去掉后,应该是
kkkuuuuuuuu
C#里,如何写正则表达式,去掉JavaScript代码?

private void Button1_Click(object sender,EventArgs e)
{
string j=去掉JavaSript的正则表达式;c=@""
this.TextBox1.Text=Regex.Replace(this.TextBox1.Text,j,c,RegexOptions.IgnoreCase);
}

解决方案 »

  1.   

    private void Button1_Click(object sender,EventArgs e)
    {
    string j=去掉JavaSript的正则表达式,c=@"";
    this.TextBox1.Text=Regex.Replace(this.TextBox1.Text,j,c,RegexOptions.IgnoreCase);
    }
      

  2.   

    private void Button1_Click(object sender,EventArgs e)
    {
    string j=去掉JavaSript的正则表达式,c=@"";
    this.TextBox2.Text=Regex.Replace(this.TextBox1.Text,j,c,RegexOptions.IgnoreCase);
    }
      

  3.   

    private void Button1_Click(object sender,EventArgs e)
    {
    string j=去掉JavaSript的正则表达式,c=@"";
    this.TextBox2.Text=Regex.Replace(this.TextBox1.Text,j,c,RegexOptions.IgnoreCase);
    }
      

  4.   

            static void Main() {
                Console.WriteLine( vallid( @"<script>window</script>
    kkk<script>window</script>
    uuuuuuuu" ) );
                Console.ReadLine();
            }        private static string vallid( string original ) {
                string j = @"<script>.*?</script>";
                return Regex.Replace( original, j, string.Empty );
            }
      

  5.   


    string j = @"(?s)<([^\s>]+)[^>]*>.*?</\1>"; c = "";
      

  6.   

    <html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Google</title><script>window.google={kEI:"tucQSqW0ItSIkQXZ6720BA",kEXPI:"17259,20429,20457",kHL:"en"};
    window.google.sn="webhp";window.google.timers={load:{t:{start:(new Date).getTime()}}};try{window.google.pt=window.gtbExternal&&window.gtbExternal.pageT()||window.external&&window.external.pageT}catch(b){}
      

  7.   

    window.google.jsrt_kill=1;
    var _gjwl=location;function _gjuc(){var e=_gjwl.href.indexOf("#");if(e>=0){var a=_gjwl.href.substring(e);if(a.indexOf("&q=")>0||a.indexOf("#q=")>=0){a=a.substring(1);if(a.indexOf("#")==-1){for(var c=0;c<a.length;){var d=c;if(a.charAt(d)=="&")++d;var b=a.indexOf("&",d);if(b==-1)b=a.length;var f=a.substring(d,b);if(f.indexOf("fp=")==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if(f=="cad=h")return 0;c=b}_gjwl.href="/search?"+a+"&cad=h";return 1}}}return 0}function _gjp(){!(window._gjwl.hash&&
    window._gjuc())&&setTimeout(_gjp,500)};
    window._gjp && _gjp();</script><style>body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}#gbar{height:22px;padding-left:2px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important;text-align:right}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.73em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}</style><script>google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};window.gbar={qs:function(){},tg:function(e){var o={id:'gbar'};for(i in e)o[i]=e[i];google.x(o,function(){gbar.tg(o)})}};</script></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f.q.focus();if(document.images)new Image().src='/images/nav_logo4.png'" topmargin=3 marginheight=3><textarea id=csi style=display:none></textarea><div id=gbar><nobr><b class=gb1>Web</b> <a href="http://images.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb1>Video</a> <a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" aria-haspopup=true class=gb3><u>more</u> <small>&#9660;</small></a><div id=gbi><a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb2>Shopping</a> <a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a> <a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://www.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a> <div class=gb2><div class=gbd></div></div><a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a> <a href="http://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=wo" class=gb2>Documents</a> <a href="http://www.google.com/reader/view/?hl=en&tab=wy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a> <div class=gb2><div class=gbd></div></div><a href="http://www.google.com/intl/en/options/" class=gb2>even more &raquo;</a> </div></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div align=right id=guser style="font-size:84%;padding:0 0 4px" width=100%><nobr><a href="http://www.google.com/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg">iGoogle</a> | <a href="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en">Sign in</a></nobr></div><center><br clear=all id=lgpd><img alt="Google" height=110 src="Google_files/logo0000.gif" width=276 id=logo onload="window.lol&&lol()"><br><br><form action="http://www.google.com/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%>&nbsp;</td><td align=center nowrap><input name=hl type=hidden value=en><input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value=""><br><input name=btnG type=submit value="Google Search">
      

  8.   

    <input name=btnI type=submit value="I'm Feeling Lucky"></td><td nowrap width=25%><font size=-2>&nbsp;&nbsp;<a href=http://www.google.com/advanced_search?hl=en>Advanced Search</a><br>&nbsp;&nbsp;<a href=http://www.google.com/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<a href=http://www.google.com/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><br><font size=-1><a href="http://www.google.com/intl/en/ads/">Advertising&nbsp;Programs</a> - <a href="http://www.google.com/services/">Business Solutions</a> - <a href="http://www.google.com/intl/en/about.html">About Google</a> - <b><a href=http://www.google.cn/>
    <!-- This document saved from http://www.google.com/ -->