超难重写正则表达式,求解?
--------------------编程问答-------------------- 自己顶一下!!!!!!!!!111 --------------------编程问答-------------------- 什么意思?表达清楚 --------------------编程问答-------------------- --------------------编程问答-------------------- 没有看懂啥意思? --------------------编程问答-------------------- 重写是用正则表达式重写的?小弟愚笨,没明白 --------------------编程问答-------------------- 莫明白。小弟前来学习! --------------------编程问答-------------------- 恩。用正则可能规则有点麻烦,不用正则容易多了。--------------------编程问答-------------------- 说来说去,只是重写了前面一小部分内容
static void Main(string[] args)
{
string[] s = new string[] { "http://www.abc.com", "http://www.abc.com?name=aa" };
for (int i = 0; i < s.Length; i++)
{
if (s[i].Contains('?'))
{
string[] fields = s[i].Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);
if (fields.Length != 2) return;//错误
s[i] = fields[0] + "/s2/index.aspx?" + fields[1];
}
else
{
s[i] += "/s1/index.aspx";
}
Console.WriteLine(s[i]);
}
Console.ReadKey();
}
<RewriterRule>
<LookFor>~/default\.aspx?(.*)</LookFor>
<SendTo>~/s1/index.aspx?$1</SendTo>
</RewriterRule>
default.aspx代表网站根目录下默认文档,根据你的修改。$1代表获取(.*匹配的内容)
试试吧 --------------------编程问答-------------------- 不懂 ,学习.... --------------------编程问答--------------------
up
补充:.NET技术 , ASP.NET