C#如何才能过滤特定的字符?例如在TextBox1里有一篇文章: 1,511 Votes Taxes are the pits, but at least they don't discriminate — everybody has to pay 'em. And that includes the leader of the free world and his right-hand man.The tax returns for President Obama and Vice President Biden were recently released to the public. Quicker than you can say "spread the wealth," searches on both documents skyrocketed. Now, normally tax returns don't inspire a lot of buzz. But when it's the Obamas' and the Bidens', the 1040s are actually pretty interesting. According to an article from Reuters, President Obama (who filed jointly with his wife, Michelle), reported an adjusted gross income of $2,656,902. They paid roughly $855,000 in federal income taxes and almost $78,000 in state income taxes.Now hold up—since when do (honest) politicians make millions of dollars? Well, normally they don't. But Mr. Obama is also a best-selling author. The majority of his 2008 income came from sales of his two memoirs, "Dreams of My Father" and "The Audacity of Hope." Interestingly, the Obamas' income took a substantial drop in 2008. According to Fox News, the couple actually pulled in $4.2 million in 2007.In comparison to his boss's return, Vice President Biden's 1040 looked downright modest. The VP and his wife reported an income of $269,256 for 2008. That's roughly a tenth of what the Obamas declared. Still, a good portion of that came from sales of Mr. Biden's memoir, "Promises to Keep." UPI reports that the Bidens reported donations of $1,885 to charity in 2008, but the White House notes that the Bidens made additional donations to their church that weren't included (lest you think they're stingy). If you'd like to take a gander at the actual tax returns, you can click here for the Obamas', and here for the Bidens'.
用户点击Button1按钮后,把括号里的注释,连同括号本身都过滤掉。
就是要一次性替换,不能像Windows的记事本里的查找功能一个个地查找,然后用空格替换。这样肯定不行,效率也非常低。而且,不同的括号里的内容也不是相同的。
我估计要用正则表达式实现这个功能。这个用C#如何实现?
用户点击Button1按钮后,把括号里的注释,连同括号本身都过滤掉。
就是要一次性替换,不能像Windows的记事本里的查找功能一个个地查找,然后用空格替换。这样肯定不行,效率也非常低。而且,不同的括号里的内容也不是相同的。
我估计要用正则表达式实现这个功能。这个用C#如何实现?
解决方案 »
- LINQ 把IQueryable<T>转换为List<List<string>>
- 正则表达式定位符问题
- 项目中的用户控件怎么添加到工具箱
- 急!急!关于用Session实现购物车的问题!
- 终于四裤衩了,散分~~ 顺便调查下有谁参加3/18微软上海发布会的吗
- TreeView 右键单击空白处也会出现节点颜色改变,如果能让右键点击空白处时颜色不改变?
- 不太明白“三层模型”是什么意思。
- 问个基础问题 关于消息的
- 求一个多客户端与服务端通信的例子。
- 关于用上传文件的问题,高手请赐教
- 用C#写的web application, 现在有两个页面A 和B,均有许多内容,想在A中调用B中的一些内容,如何做方便??
- TreeView绑定表名gridview显示点击的表 如何对表进行增删改??
{
Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
//删除HTML
Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase); Htmlstring.Replace("<", "");
Htmlstring.Replace(">", "");
Htmlstring.Replace("\r\n", "");
Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim(); return Htmlstring;
}
Regex.Replace(输入, @"\([^\)]\)", "", RegexOptions.IgnoreCase);
打开帖子才出去一下而已,结果回帖比wuyi8808慢了7分钟
看来是太久不抢分了,速度明显比不上当年了
Regex.Replace(输入, @"\([^()]*\)", "", RegexOptions.IgnoreCase);