C#初学者:删除字符串中两个字符之间的所有字符(正则表达式?) [英] C# Beginner: Delete ALL between two characters in a string (Regex?)

查看:39
本文介绍了C#初学者:删除字符串中两个字符之间的所有字符(正则表达式?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带html代码的字符串.我想删除所有的html标签.因此,所有<之间的字符和>.

i have a string with an html code. i want to remove all html tags. so all characters between < and >.

这是我的代码片段:

WebClient wClient = new WebClient();
SourceCode = wClient.DownloadString( txtSourceURL.Text );
txtSourceCode.Text = SourceCode;
//remove here all between "<" and ">"
txtSourceCodeFormatted.Text = SourceCode;

希望有人可以帮助我

推荐答案

尝试一下:

txtSourceCodeFormatted.Text = Regex.Replace(SourceCode, "<.*?>", string.Empty);

但是,正如其他人提到的那样,请谨慎处理.

But, as others have mentioned, handle with care.

这篇关于C#初学者:删除字符串中两个字符之间的所有字符(正则表达式?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆