如何substr或strpos这个字符

时间:2013-07-13 11:28:12

标签: substring strpos

帮我把这个角色放在一个代码中

  1. 4edtee3fdpd0h8o
  2. kfz254yae7cw8fb
  3. da84s08ifannjs6
  4. a4x4c1eaki9ekw1
  5. 从这个网址:所有这个$ char

    1. httpq://199.91.153.79/c0l8y769haig/4edtee3fdpd0h8o/1-No%26Batak+%2B+JB.mp3
    2. httpq://199.91.153.63/7otxr1alp53g/kfz254yae7cw8fb/1-Yes%26metalica.mp3
    3. httpq://205.196.120.88/x0xa2u3s6utg/da84s08ifannjs6/1-Yes%26Mirrors.mp3
    4. httpq://205.196.122.248/dv6dyax7o3eg/a4x4c1eaki9ekw1/1-Yes%26reggae.mp3
    5. 先谢谢..

1 个答案:

答案 0 :(得分:0)

你需要这个正则表达式

/httpq:\/\/([\d+]{1,3}[\.|\/])+[^\/]+\/(\S+)\/.*/

示例:

$str = "httpq://199.91.153.63/7otxr1alp53g/kfz254yae7cw8fb/1-Yes%26metalica.mp3";
$regex = "/httpq:\/\/([\d+]{1,3}[\.|\/])+[^\/]+\/(\S+)\/.*/";
echo preg_replace($regex, "$2", $str);