------art_32616_2093869.1171316970567
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Well, maybe you can assume valid XML and parse the page with REXML. If it's
not valid XML, well you can regex through for (off-the-cuff, probably wrong)
/<param.*value.*)"/ and use the result. Someone more knowledgable in
Regexps can help you out if it comes to this.

Jason

On 2/12/07, Dave Hoefler <dhoefler / gmail.com> wrote:
>
> Hi there,
>
> I have a question about string search and replacement. Let's say I have
> this
> string that contains 2 <object> links for embedding youtube videos amongst
> some other random text.
>
> string  We've got some junk text here" +
>          "<object width425\" height350\"><param namemovie\"
> valuehttp://www.youtube.com/v/qqsyXdj_p_I\"></param>" +
>          "<param namewmode\" valuetransparent\"></param><embed
> src
> http://www.youtube.com/v/qqsyXdj_p_I\"
> typeapplication/x-shockwave-flash\"" +
>          "wmodetransparent\" width425\"
> height350\"></embed></object>" +
>          "And we've got some more junk text right here" +
>          "<object width425\" height350\"><param namemovie\"
> valuehttp://www.youtube.com/v/yYqACgndOQA\"></param>" +
>          "<param namewmode\" valuetransparent\"></param><embed
> src
> http://www.youtube.com/v/yYqACgndOQA\"
> typeapplication/x-shockwave-flash\"" +
>          "wmodetransparent\" width425\"
> height350\"></embed></object>" +
>          "more garbage text here"
>
> I'd like to get the value of the 'value' attributes ("
> http://www.youtube.com/v/qqsyXdj_p_I" and "
> http://www.youtube.com/v/yYqACgndOQA" respectively) and convert the string
> into the following:
>
> We've got some junk text here
> <div idoutube_qqsyXdj_p_I"></div>
> <script typeext/javascript">
>     var so  ew SWFObject("http://www.youtube.com/v/qqsyXdj_p_I",
> "qqsyXdj_p_I", "425", "350", "6","","","","","");
>     so.write("youtube_qqsyXdj_p_I");
> </script>
> And we've got some more junk text right here
> <div idoutube_yYqACgndOQA"></div>
> <script typeext/javascript">
>     var so  ew SWFObject("http://www.youtube.com/v/yYqACgndOQA",
> "yYqACgndOQA", "425", "350", "6","","","","","");
>     so.write("youtube_yYqACgndOQA");
> </script>
> more garbage text here
>
>
> What would be the best library to use for parsing and replacing certain
> values in a string? I've done simple .gsub'ing before, but this seems to
> be
> a little more complicated ;-)
>
> Thanks,
> Dave Hoefler
>

------art_32616_2093869.1171316970567--