Converting youtube and google video embed HTML into a SWFObject

Hi there,

Is there a small ruby / rails library that formats youtube or google video HTML embed code into SWFObject ( HTML? The code youtube and google video provide doesn’t always play nice in IE apparently (that’s what one of our CSS gurus at work told me).

So I’m looking to turn this (which doesn’t play nice in all browsers):

<object width="425" height="350">
    <param name="movie" value="[](">


into this:

The project I’m working on is a social community and we’re trying to keep the comments people post on profile pages as valid as possible.


I forgot to mention, the whole site is in Rails… so that’s why I’m asking here :slight_smile:

Here’s a little more info on the issue:

Let’s say I have this string that contains 2 links for embedding youtube videos amongst some other random text.

string = “We’ve got some junk text here” +

     "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"[\](\)"></param>" +

     "<param name=\"wmode\" value=\"transparent\"></param><embed src=\"[\](\)" type=\"application/x-shockwave-flash\"" +
     "wmode=\"transparent\" width=\"425\" height=\"350\"></embed></object>" +
     "And we've got some more junk text right here" +
     "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"

[](">" +
“<param name=“wmode” value=“transparent”><embed src=”
[](" type=“application/x-shockwave-flash”" +
“wmode=“transparent” width=“425” height=“350”>” +

     "more garbage text here"

I’d like to get the value of the ‘value’ attributes (“” and "" respectively) and convert the string into the following:

We’ve got some junk text here

And we’ve got some more junk text right here

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 :wink:

Dave Hoefler