正则表达式 :时间:(\d{4}-\d{2}-\d{2})(.+?)</table>
匹配的字符串:时间:2008-07-02tfhtrtryrt时间:2008-06-30ghjhewrewrwerewrewrewrewrew</table>我想匹配第二个日期和中间的字符串,现在老是匹配第一个日期。各位高手踊跃发言啊!!

解决方案 »

  1.   

    想要的结果为时间:2008-06-30ghjhewrewrwerewrewrewrewrew </table>
      

  2.   

     @"时间:\d{4}-\d{2}-\d{2}\w* </table>"
      

  3.   

    最后加个参数,RegexOptions.RightToLeft
      

  4.   

    明明整个都匹配
    时间:2008-07-02tfhtrtryrt时间:2008-06-30ghjhewrewrwerewrewrewrewrew </table>
    你说只匹配第一个是什么意思?
      

  5.   

    lye2000000_super
    你的表达式 无法匹配 带空格的啊,\w匹配包括下划线的任何单词字符。等价于'[A-Za-z0-9_]'。匹配不了空格啊
      

  6.   

    时间:.*(时间:[\d{4}-\d{2}-\d{2}].*)</table>
      

  7.   

    时间:.*(时间:[\d{4}-\d{2}-\d{2}].*?</table>)时间:2008-06-30ghjhewrewrwerewrewrewrewrew </table>
    是这个结果啊...
      

  8.   

    @"时间:\d{4}-\d{2}-\d{2}.* </table>";
    这样就可以了。
      

  9.   

    string test = "时间:-07-02tfhtrtryrt时间:-06-30ghjhewrewrwerewrewrewrewrew </table>";
    Match m = Regex.Match(test, @"时间:(\d{4}-\d{2}-\d{2})(((?!时间:).)*)</table>", RegexOptions.IgnoreCase);
    if (m.Success)
    {
        MessageBox.Show(m.Groups[1].Value + "\n" + m.Groups[2].Value);
    }
      

  10.   

    汗,怎么字符串里的年会不见了
    string test = "时间:2008-07-02tfhtrtryrt时间:2008-06-30ghjhewrewrwerewrewrewrewrew </table>";
    Match m = Regex.Match(test, @"时间:(\d{4}-\d{2}-\d{2})(((?!时间:).)*)</table>", RegexOptions.IgnoreCase);
    if (m.Success)
    {
        MessageBox.Show(m.Groups[1].Value + "\n" + m.Groups[2].Value);
    }