111,126
社区成员
发帖
与我相关
我的任务
分享Regex reg = new Regex(@"<%\s*=[\s\S]*?%>");Regex reg = new Regex(@"<%[ ]*=[\s\S]*?%>");简洁,明了。谢谢,结贴啦!Regex reg = new Regex(@"<%=[\s\S]*?%>");Regex reg = new Regex(@"<%=([^>]*|" + "[^\"\">]*\"[^\"\"]*\"\"[^>]*)%>");
string result = string.Empty;
string temp = "alsj <%=dd%> kkj <%= dd.GetName(\" He!you# <br>\"+MSG )%> lb.Text= \"\"+Helo; lbt.Text= ToMSG";
foreach (Match m in reg.Matches(temp))
{
result += m.Value + "\r\n";
} Regex reg = new Regex(@"<%=([^>]*|" + "[^\"\">]*\"[^\"\"]*\"\"[^>]*)%>");
string result = string.Empty;
string temp = "alsj <%=dd%> kkj <%= dd.GetName(\" He!you# <br>\"+MSG )%> lb.Text= \"\"+Helo; lbt.Text= ToMSG";
foreach (Match m in reg.Matches(temp))
{
result += m.Value + "\r\n";
} Regex reg = new Regex(@"<%=\s*dd([^>]*|" + "[^\"\">]*\"[^\"\"]*\"\"[^>]*)%>");
string result = string.Empty;
string temp = "alsj <%=dd%> kkj <%= dd.GetName(\" He!you# <br>\"+MSG )%> lb.Text= \"\"+Helo; lbt.Text= ToMSG";
foreach (Match m in reg.Matches(temp))
{
result += m.Value + "\r\n";
}修改了下进行的测试,还是只能找到第一个<%=dd%>,还有这种情况<%=A.GetName("<script>alert(10)</script>")%>,是允许里面有<,>的。所以你的表达式还是有问题的。麻烦再看看哈!Regex reg=new Regex(@"<%=\s*dd([^>]*|[^"">]*\"[^""]*""[^>]*)%>");
string result=string.Empty;
foreach(Match m in reg.Matches("你的字符串"))
{
result+=m.Value+"\r\n";
}Regex reg=new Regex(@"<%=\s*dd([^>]*|[^"">]*\"[^""]*""[^>]*)%>");