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 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型