【发布时间】:2013-04-20 14:15:50
【问题描述】:
我一直在尝试使用正则表达式匹配 HTML 文件中的 cmets,并通过 C#.net (VS2010) 解决方案将它们完全删除。 这是 cmets 的样子,
/*This flexibility is not available with most other programming languages. E.g. in Java,
the position for \G is remembered by the Matcher object.
The Matcher is strictly associated with a single regular expression and a single subject
string.*/
我确实尝试过/\*.+\*/,
str = File.ReadAllText("Test.html");<br />
str = Regex.Replace(str, "/\*.+\*/", "", RegexOptions.Singleline);<br />
File.WriteAllText("Test.html", str);
但他们不适合我。我在论坛中关注了一些答案,但仍然没有运气。
如果有任何帮助,我将不胜感激:)
谢谢...
【问题讨论】:
-
您是否在 HTML 中搜索 c# cmets?因为那时您需要选择
/*和*/之间的所有内容? -
不,Izzy,它是 HTML 文件中的 cmets :)
-
不要 html cmets 看起来像这样 ? :D
-
@RaheelHasan 这就是我感到困惑的原因:)
-
其中一些是。我已经设法删除了它们,但留下了 /* ... */。