帮忙写个PHP正则表达式

来源:百度知道 编辑:UC知道 时间:2024/05/13 19:15:23
[media=mov,400,300]http://www.xxx.com[/media]


http://www.xxx.com
提取出来..用PHP来写..

<?php

$str = "[media=mov,400,300]http://www.xxx.com[/media] [media=mov,400,300]http://www.xxx.com[/media] [media=mov,400,300]http://www.xxx.com[/media] ";

if(preg_match_all('|\[media.*\](.*)[/media\]|Ui', $str, $urls)){
var_dump($urls);
}

下面的例子代码能完成提取,程序调试通过,你可以借鉴里面的正则:

<?php
$str='[media=mov,400,300]http://www.xxx.com[/media]';
if (preg_match_all('|\](.*?)\[|', $str, $reg)) print_r($reg[1]);
?>

<?
$str = "[media=mov,400,300]http://www.xxx.com[/media]";
$pattern = &q