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";
精彩评论