C# 如何删除以#using regex开头的所有字符串?

C# 如何删除以#using regex开头的所有字符串?,c#,regex,C#,Regex,我有一个HTML页面,我想删除内容中出现的所有颜色 我需要一个正则表达式模式来删除它,例如: input: this is the page content #ffffff another text output: this is the page content , another text 我该怎么做呢?根据描述,您可以简单地使用“#\w+”或“#\w{6}”(不带引号)。 但是,为什么在给定的示例中有一个额外的逗号?确保只是输入错误或进一步澄清问题的描述。您可以执行以下操作: con

我有一个HTML页面,我想删除内容中出现的所有颜色

我需要一个正则表达式模式来删除它,例如:

input:  this is the page content #ffffff another text

output: this is the page content , another text

我该怎么做呢?

根据描述,您可以简单地使用“#\w+”或“#\w{6}”(不带引号)。
但是,为什么在给定的示例中有一个额外的逗号?确保只是输入错误或进一步澄清问题的描述。

您可以执行以下操作:

const string regex = @"#\w{6}";
var r = new Regex(regex, RegexOptions.IgnoreCase);
str = r.Replace(str, "");

编写代码将是一个很好的开始…向我们展示您所做的工作,也许我们可以提供帮助。在vim中,这项工作:
%s/\\\\\.*//g
我有html页面内容,我想删除除文本以外的所有内容,我删除了所有内容,但仍然显示颜色,因此我希望使用正则表达式模式将其删除@jamesshaw如果您尝试使用html,我建议你考虑一下使用。