62,041
社区成员
发帖
与我相关
我的任务
分享
string a = @"
function b(){
getScript(""http://www.aa.com/bb.js"");}";
Regex reg = new Regex(@"getScript\((['""])([^'""]+)\1\)\s*;");
Response.Write(reg.Match(a).Groups[2].Value + "<br/>");
Response.Write(reg.Replace(a, ""));
/*
http://www.aa.com/bb.js
function b(){ }
*/
string result = string.Empty;
string a = "function b(){getScript(\"http://www.aa.com/bb.js\");}";
Regex re = new Regex("(?<=\\\").*?(?=\\\")", RegexOptions.None);
Regex re1 = new Regex("(?<={).*?(?=})", RegexOptions.None);
result = re.Match(a).Value; //这是提取的:http://www.aa.com/bb.js
a = re1.Replace(a, ""); //这是替换后的:function b(){}