获取字符串之间的字符串preg_match [关闭]

i have this preg_match in php to get the url string between to string. but my problem is i can't get any data out of it

preg_match( "/\[(gmap)\](.*?)\[\/(gmap)\]/si", $content, $url)

i need to get the string inside of this string

[gmap]http://maps.google.com/maps/api/staticmap?zoom=15&size=325x125&maptype=roadmap&markers=color:purple|40.718217,-73.998284&sensor=false[/gmap]

but i can't get a result. why?

$url[2]

i need to have

http://maps.google.com/maps/api/staticmap?zoom=15&size=325x125&maptype=roadmap&markers=color:purple|40.718217,-73.998284&sensor=false

This works perfectly fine :

<?php
  $url="";
   $content = '[gmap]http://maps.google.com/maps/api/staticmap?zoom=15&size=325x125&maptype=roadmap&markers=color:purple|40.718217,-73.998284&sensor=false[/gmap]';
    preg_match( "/\[(gmap)\](.*?)\[\/(gmap)\]/si", $content, $url);
    print  $url[2];

    ?>

Cheers!

It's possible that you got an issue because the .* also includes the [ character. You could use this instead :

preg_match("/\[(gmap)\]([^\[]*)?\[\/(gmap)\]/si", $content, $url);