C#Beginner:在字符串中的两个字符之间删除ALL(正则表达式?)

 zhongxiaomin1981 发布于 2023-02-13 15:56

我有一个带有HTML代码的字符串.我想删除所有的HTML标签.所以<和>之间的所有字符.

这是我的代码剪辑:

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

希望有人能帮助我

1 个回答
  • 试试这个:

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

    但正如其他人所说,小心处理.

    2023-02-13 16:00 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有