CodeIgniter Forums
Regular Expression - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Regular Expression (/showthread.php?tid=7256)



Regular Expression - El Forum - 04-01-2008

[eluser]nirbhab[/eluser]
Quote:&lt;object width="425" height="355"&gt;<param name="movie" value="http://www.youtube.com/v/SZPz8gaFaEE&hl=en"></param><param name="wmode" value="transparent"></param>&lt;embed src="http://www.youtube.com/v/SZPz8gaFaEE&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;

Guys how to find the bold string from the above string

Hope you have got my idea.
I want add the youtube videos in my site, added as user videos..some what like orkut does.
I am going to extract the source of flash file, and save in DB_table with user_id(logged in user).

If my plan is wrong please suggest a better way.


Regular Expression - El Forum - 04-01-2008

[eluser]xwero[/eluser]
/src="(.+?)" type/ should do it.


Regular Expression - El Forum - 04-01-2008

[eluser]nirbhab[/eluser]
Its not working..returning a empty array()

Code:
$pattern = '/&lt;embed[^&gt;]+src[\\s=\'"]';
$pattern .= '+([^"\'>\\s]+)/is';
This one is working fine...but, is it right way to perform the task?


Regular Expression - El Forum - 04-01-2008

[eluser]Pascal Kriete[/eluser]
xwero has it right, but regular expression tester reveals that your snippet has funny quotes. So a cheap hack would be:
Code:
$patthern = '/src=[^a](.+?)[^a] type/';