重新设计一种权限体系的时候,遇到了一些问题,于是有了下面的一段代码,备份在此
看的懂俺这代码的,说明水平已经不错了 :)
protectedstringParseAspxTag(stringstr)

...{
strings="";
intk,m,n;
stringstrKey="";
while(str.IndexOf("<asp:")>0)

...{
k=str.IndexOf("<asp:");
m=0;
n=k;
while(m==0)

...{
m=str.IndexOf(">",n);
if((str.Substring(k,m-k+1).Split('"').Length%2)==0)

...{
n=m+1;
m=0;
}
else

...{
strKey=str.Substring(k,m-k+1);
str=str.Replace(strKey,"");
if(strKey.IndexOf("/>")<=0)

...{
strKey=strKey.Replace(">","/>");
}
break;
}
}
strKey=strKey.Replace("<asp:","<");
//thefollowingcodejustasimplesolution,ifstringexistsomewordhavenot'"',addit
strKey=strKey.Replace(" ","");
for(intl=0;l<strKey.Length;l++)

...{
if(strKey[l]=='='&&(strKey.Substring(1,l).Split('"').Length%2)==1)

...{
if(strKey[l+1]!='"')

...{
intc=strKey.IndexOf("",l);
strKey=strKey.Insert(c,""");
strKey=strKey.Insert(l+1,""");
l=0;
}
}
}
s+=strKey+" ";

}
s="<?xmlversion="1.0"encoding="utf-8"?><Root>"+s+"</Root>";
returns;
}
俺没有使用正则表达式,俺不熟,习惯于使用笨办法解决简单问题