dream12001 2015-11-17 13:19
浏览 30
已采纳

按格式查找事件? [关闭]

Let's say we have this string: http://192.168.1.1:8080/something/something.s01e01.2013.HDTVRip.XViD.AC3.LT.avi.mp4

I need to check if string has occurrency like this: s01e01 or s01e02, or s08e06 or etc. and then parse the numbers(s01e03 -> 1 and 3). How could I do that?

  • 写回答

1条回答 默认 最新

  • doudao1369 2015-11-17 13:29
    关注

    Do this:

    $matches = array();
    $string = 'http://192.168.1.1:8080/prOn/prOnTube.s01e01.2013.HDTVRip.XViD.AC3.LT.avi.mp4';
    preg_match ( '/s([0-9]{2})e([0-9]{2})/i' , $string, $matches );
    
    $season = intval($matches[1]);
    $episode = intval($matches[2]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真