日期:2014-05-18 浏览次数:20975 次
string tempStr = @"<script src=""../../Jscript/jquery-1.6.4.min.js"" language=""javascript"" type=""text/javascript""></script>"; string pattern = @"(?i)(?<=<script[^>]*?src=(['""])[^'""]*)(?=\1[^>]*?>)"; string result = Regex.Replace(tempStr, pattern, "?tt=dd");
------解决方案--------------------
没写完整
string input=@"<script src=""../../Jscript/jquery-1.6.4.min.js"" language=""javascript"" type=""text/javascript""></script>"; Regex.Replace(input,@"(?i)js(?="")",@"$0?tt==dd");
------解决方案--------------------
string html = @"<script src=""../../Jscript/jquery-1.6.4.min.js"" language=""javascript"" type=""text/javascript""></script>";
Regex reg = new Regex(@"(?i)<script (?:[^>]*?)src=[""'][^""']+");
html = reg.Replace(html, "$0?tt=" + DateTime.Now.Ticks);
Console.WriteLine(html);
===输出
<script src="../../Jscript/jquery-1.6.4.min.js?tt=634726852429582117" language="javascript" type="text/javascript"></script>