regex - Using PHP's preg_match_all to extract a URL -
i have been struggling while make following work. basically, i'd able extract url expression contained in html template, follows:
{rssfeed:url(http://www.example.com/feeds/posts/default)}
the idea that, when found, url extracted, , rss feed parser used rss , insert here. works, example, if hardcode url in php code, need regex figured out template flexible enough useful in many situations.
i've tried @ least ten different regex expressions, found here on so, none working. regex doesn't need validate url; want find , extract it, , delimiters url don't need parens, either.
thank you!
/\{rssfeed\:url\(([^)]*)\)\}/
preg_match_all('/\{rssfeed\:url\(([^)]*)\)\}/', '{rssfeed:url(http://www.example.com/feeds/posts/default)}', $matches, preg_pattern_order); print_r($matches[1]);
you should able urls on content available in $matches[1]
..
note: urls {rssfeed:url()}
format, not urls in content.
you can try here: http://www.spaweditor.com/scripts/regex/index.php
Comments
Post a Comment