3
我有以下代碼:如何修復刪除HTML註釋的正則表達式從刪除條件註釋?
source = Regex.Replace(source, "<!--.*?-->", string.Empty, RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled);
...並能正常工作,但它也除掉條件註釋:
<!--[if IE]>???<![endif]-->
誰能告訴我如何更新正則表達式,因此不刪除條件註釋?
如果它跟你想要的東西像正則表達式的傳統規則: Regex.Replace(來源: 「< - \ S [^ \\] * - !?。?>」 字符串。空,RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled); 例如。 '忽略任何空格,如果有[註釋開始後的標記],則不匹配。 – Soz