开发者

Get an URL from text surrounded with curly braces using PHP Regular expression

I have the following text (inside some more text): {movie:http://www.film.com/films/film1}

I would like to use a reg开发者_StackOverflow社区ular expression to get the url based on the fact that it's wrapped inside curly braces and contains "movie:" after the first brace. How can I do this using PHP?


$t = "{movie:http://www.film.com/films/film1}";
preg_match(/{movie:([^}]+)}/,$t,$m);
$url = $m[1];


Try this:

if (preg_match('/\{movie:(.*?)}/', $text, $match))
    print "Found movie URL '".$match[1]."'\n";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜