日期:2014-05-18  浏览次数:20751 次

听说这里的正则高手特多,特来问一简单问题
HTML code

[color=#FF0000]xxx = true; // Remove old files[/color]

// 5 minutes execution time
afdsfs
        
// Uncomment this one to fake upload time
// asdf

af

   // Uncomment this one to fake upload time

fda

     // Uncomment this one to fake upload time333



我想删除 有//的行 ,//有可能不是在开头 。参见红色部分,如果 //在表达式的后面,是不删除的。
正则应该如何写

------解决方案--------------------

C# code
        string r = Regex.Replace(s, @"(?m)^\s*//.*$", "");

------解决方案--------------------
探讨

C# code

string pat = @"(?is)^([^\S]*)//[^\r\n]*";
Regex rx = new Regex(pat);
string replacestr = rx.Replace(input, "$1");//input你的htmlcode

------解决方案--------------------
str=Regex.Replace(str,"(?m)^\\s*//.*","");