user1756209 user1756209 - 2 months ago 40
Java Question

Regex YouTube IFRAME

Possible Duplicate:

How to parse and process HTML with PHP?

I want to publish an app for android (wordpress blog). The app displays also some YouTube videos.
I need a method to replace YouTube IFRAMES + EMBED-Codes (old embed method) with an a - tag:

<iframe ...

<a href=""><img src="" /></a>

The replacement: either via php (server) or via java (eclipse). I have only found some snippets...


But how could I use it? Please help me!

EDIT: I try to replace the following CODE:

<iframe width="560" height="315" src="**ID**" frameborder="0" allowfullscreen></iframe>


$content = "contains <iframe... and article"
$search = '/<iframe.+?src="[a-zA-Z0-9_-]{11})"[^>]+?></iframe>/i';
$replace = '<a href="$1"><img src="$1/hqdefault.jpg" /></a>';
$content = preg_replace($search, $replace, $content);
echo $content;

How could I used it? Error: Unknown modifier '/' (in PHP).


Try this :