62,243
社区成员




string path = "http://XXX.XXXX.XXX/XXX/VIP_XX/report/aaa.aspx?id=1";
Match match = Regex.Match(path, @"/(?i)([^/]+)/(report(/[^/?]*)*)");
Response.Write(match.Groups[1].Value + "<br/>");
Response.Write(match.Groups[2].Value);
Regex reg = new Regex(@"(?i)(?<=/)(VIP_[^/]+)/([^?\s]+)");
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups[1].Value + "\n";
richTextBox2.Text += m.Groups[2].Value + "\n";
}
Regex reg = new Regex(@"(?i)(?<=/)VIP_[^?\s]+");
string path = "http://XXX.XXXX.XXX/XXX/VIP_XX/report/aaa.aspx?id=1";
path = Regex.Match(path,@"(?i)(?<=/)([^\?/]+/?){3}(?=\?|$)").Value;
//VIP_XX/report/aaa.aspx
string path = "http://XXX.XXXX.XXX/XXX/VIP_XX/report/aaa.aspx?id=1";
Uri uri = new Uri(path);
string r1 = uri.Segments[uri.Segments.Length - 3].Trim('/');
string r2 = uri.Segments[uri.Segments.Length - 2] + uri.Segments[uri.Segments.Length - 1];
Response.Write(r1 + "<br/>");
Response.Write(r2);
string path = "http://XXX.XXXX.XXX/XXX/VIP_XX/report/aaa.aspx?id=1";
path = Regex.Match(path,@"(?i)(?<=/\w{3}_\w{2}/)[^\?]+").Value;
//report/aaa.aspx