求正则表达式现有文件目录
C:\web\web.otel.com\19\tt32.jsp
D:\w\www.eotel.com\17\tt56.html
E:\eb\msm.eghtel.com\51\t56t.htm
H:\wweb\new.eghotel.cn\101\t789t.aspx用什么正则表达式才能匹配的取出目录中的网址部分呢?web.otel.com\19\tt32.jsp
www.eotel.com\17\tt56.html
msm.eghtel.com\51\t56t.htm
new.eghotel.cn\101\t789t.aspx

解决方案 »

  1.   

    try:
                string s = @"C:\web\web.otel.com\19\tt32.jsp";
                Regex regex=new Regex(@"^[^\\]*\\[^\\]*\\(.+) *$");
                Match match = regex.Match(s);
                string result = match.Groups[1].Value;
                MessageBox.Show(result);
      

  2.   

    to:kissknife(侧身向南边)你就是个骗子,你的代码经过测试了么?对人家负责好不?
      

  3.   

    to:kissknife(侧身向南边)你就是个骗子,你的代码经过测试了么?对人家负责好不=======================================================
      

  4.   

    String Extension(String url)
    {
    Regex r = new Regex(@"(?<web>(\w+\.){2,}\w+\\\d+\\(\w+\.\w+))", RegexOptions.Compiled);
    return r.Match(url).Result(@"${web}");
    }
      

  5.   

    况且我说了try了,就是让楼主参考参考,你懂英文不...不会的话别在这里乱叫...这年头,什么人都有,服了
      

  6.   

    again
    string pattern=@"(\w+\.){1,}.+";Regex r=new Regex(pattern,RegexOptions.IgnoreCase);
    Match m=r.Match(str1);
    Console.WriteLine(m.Value);
      

  7.   

    引用fengfangfang() 可以匹配// Regex match
    RegexOptions   options = RegexOptions.None;
    Regex          regex = new Regex(@"(?<web>(\w+\.){2,}\w+\\\d+\\(\w+\.\w+))", options);
    string         input = @"H:\wweb\new.eghotel.cn\101\t789t.aspx"; // Check for match
    bool   isMatch = regex.IsMatch(input);
    if( isMatch )
    {
    // TODO: Do something with result
    System.Windows.Forms.MessageBox.Show(input, "IsMatch");
    } // Get match
    Match   match = regex.Match(input);
    if( match != null )
    {
    // TODO: Do something with result
    System.Windows.Forms.MessageBox.Show(match.Value, "Match");
    }
      

  8.   

    我一般反其道行之
    string a=Regex.Replace(@"C:\web\web.otel.com\19\tt32.jsp",@"\w:\\|\w+\\","");