What I am trying to do is swap out any object references to YouTube videos, and replace them with their thumbnail reference along with a call to an internal method which passes the YouTube ID.
A sample body text may look like this:
This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Qw_uJCnL_Ls&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Qw_uJCnL_Ls&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test This is a my test
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Qw_uJCnL_Ls&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Qw_uJCnL_Ls&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
What I would like the regex to do is output something like this:
<img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID/default.jpg" onclick="handleOpenMeidaBox("youtube", YOUTUBE_VIDEO_ID)" />
It basically strips out the YOUTUBE_VIDEO_ID from the object tags which is the value between the "v/" and the next "&" such as "Qw_uJCnL_Ls" is in this example: http://www.youtube.com/v/Qw_uJCnL_Ls&
I was thinking of breaking this down into a bunch of smaller easier to manage blocks, but was trying to avoid all the nested loops. Any ideas would be great!