Reputation: 1486
I have the following text (inside some more text): {movie:http://www.film.com/films/film1}
I would like to use a regular 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?
Upvotes: 0
Views: 512
Reputation: 58541
$t = "{movie:http://www.film.com/films/film1}";
preg_match(/{movie:([^}]+)}/,$t,$m);
$url = $m[1];
Upvotes: 3
Reputation: 2434
Try this:
if (preg_match('/\{movie:(.*?)}/', $text, $match))
print "Found movie URL '".$match[1]."'\n";
Upvotes: 0