我一直在嘗試使用正則表達式匹配HTML文件中的註釋,並通過C#.net(VS2010)解決方案完全刪除它們。 這裏是怎麼樣的樣子,正則表達式匹配多行註釋
/*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#註釋?因爲那麼你需要選擇'/ *'和'* /'之間的所有東西? – Izzy 2013-04-26 12:11:49
沒有Izzy,它是在HTML文件中的評論:) – Mayura 2013-04-26 14:11:12
不要HTML評論看起來像這樣<! - comment - >? :D – 2013-04-26 14:30:22