有固定格式的字符串:A/B/C,(A、B、C是int或者doublel類型),例如
"2299/1/1.00"
"1027/2/2.00"
需要提取第二個"/"開始後的數字
"2299/1/1.00"  提取 1.00
"1027/2/2.00"  提取 2.00非常感謝大家了!

解决方案 »

  1.   


    (?<=(\d+(\.\d+)?\/){2})\d+(\.\d+)?
      

  2.   

    謝謝
    不過我現在隻知道 Regex.IsMatch來匹配,還不會用它來提取
    我先找找
      

  3.   

    IsMatch不能提取,
    用Match或Matchs
      

  4.   


    Regex reg=new Regex(@"(?<=(?:\d+(?:\.\d+)/){2})\d+(\.\d+)");
    string result=string.Empty;
    foreach(Match m in reg.Matches("你的字符串"))
    {
     result+=m.Value+"\r\n";
    }
      

  5.   

    改成:
    Regex reg=new Regex(@"(?<=(?:\d+(?:\.\d+)?/){2})\d+(?:\.\d+)?");
      

  6.   


    System.Text.RegularExpressions.Regex r=new System.Text.RegularExpressions.Regex("(?<=(\\d+(\\.\\d+)?\\/){2})\\d+(\\.\\d+)?");
    System.Text.RegularExpressions.Match m=r.Match("1027/2/2.00");string strResult=m.value;