SDLHZ 2016-09-26 03:08 采纳率: 0%
浏览 1523
已结题

c# 正则匹配 特殊字符串

我要把下面路径中的 "log_error.log" 这段字符串匹配出来 正则怎么写
C:\Users***\Perforce\EASAP\jiawang_EASHDPDESK257_6678\nucleus\SANDBOX\henryzhu\ProductAPIValidator\ProductAPIValidator\bin\Debug\log_error.log

  • 写回答

1条回答 默认 最新

  • Go 旅城通票 2016-09-26 03:49
    关注
     string s=@"C:\Users***\Perforce\EASAP\jiawang_EASHDPDESK257_6678\nucleus\SANDBOX\henryzhu\ProductAPIValidator\ProductAPIValidator\bin\Debug\log_error.log";
    string []arr=s.Split('\\');//arr[arr.Length-1]就是
    

    正则用这个

             Regex r = new Regex(@"\\([^\\]+)$");
            string s = @"C:\Users***\Perforce\EASAP\jiawang_EASHDPDESK257_6678\nucleus\SANDBOX\henryzhu\ProductAPIValidator\ProductAPIValidator\bin\Debug\log_error.log";
            Match match = r.Match(s);
            Response.Write(match.Groups[1].Value);
            Response.End();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误