将 unicode 添加到字符串 html 标记模式

Add unicode to a string html tag pattern

当在 SSIS 中 运行 时,我正在使用下面的 C# 脚本从描述列中删除 HTML 标签。我试图将以下 unicode : 添加到下面的字符串 htmlTagPattern 中,但我无法让它工作。

如有任何帮助,我们将不胜感激。

public class ScriptMain : UserComponent
{
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {    
         Row.Message = RemoveHtml(Row.Message);
    }
   public String RemoveHtml(String message)
   {
       String htmlTagPattern = "<(.|\n)+?>";
        Regex objRegExp = new Regex(htmlTagPattern);
        message = objRegExp.Replace(message, String.Empty);
        return message;
    }
}

将HTML转为纯文本的方法有很多:

使用 HTMLAgilityPack 库

您可以从提供的示例中获取代码:

您可以从以下链接下载 HTMLAgilitypack:

使用System.Net

如果您使用的是 .Net framework 4 或更高版本,您可以受益于 System.Net 库,该库包含从 HTML:

获取纯文本的方法
System.Net.HttpUtility.HtmlDecode(Row.Column)

参考:

使用正则表达式

您可以点击以下链接之一了解更多详情:

  • How can I strip HTML tags from a string in ASP.NET?
  • C# Remove HTML tags
  • How do you convert Html to plain text?